/* TameerERP - shared application styles */

:root {
    --tameer-primary: #b45309;   /* construction amber */
    --tameer-primary-dark: #92400e;
    --tameer-ink: #1e293b;
    --tameer-muted: #64748b;
    --tameer-surface: #f1f5f9;

    --tameer-sidebar-bg: #0f172a;
    --tameer-sidebar-ink: #cbd5e1;
    --tameer-sidebar-ink-dim: #64748b;

    --tameer-sidebar-width: 258px;
    --tameer-sidebar-rail: 68px;
    --tameer-topbar-height: 60px;
}

body {
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--tameer-ink);
    background-color: var(--tameer-surface);
}

.btn-tameer {
    background-color: var(--tameer-primary);
    border-color: var(--tameer-primary);
    color: #fff;
}

.btn-tameer:hover,
.btn-tameer:focus {
    background-color: var(--tameer-primary-dark);
    border-color: var(--tameer-primary-dark);
    color: #fff;
}

.btn-tameer:disabled {
    background-color: var(--tameer-primary);
    border-color: var(--tameer-primary);
    color: #fff;
    opacity: .65;
}

.text-tameer { color: var(--tameer-primary); }

.form-label {
    font-weight: 600;
    font-size: .875rem;
}

/* =============================================================================
   Login (standalone page - does not use Site.Master)
============================================================================= */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #0f172a 0%, #334155 55%, #78350f 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    border: none;
    border-radius: .9rem;
    box-shadow: 0 1.25rem 2.5rem rgba(15, 23, 42, .35);
}

.login-brand {
    width: 56px;
    height: 56px;
    border-radius: .75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--tameer-primary);
    color: #fff;
    font-size: 1.75rem;
}

.login-card .form-control:focus {
    border-color: var(--tameer-primary);
    box-shadow: 0 0 0 .2rem rgba(180, 83, 9, .2);
}

/* =============================================================================
   App shell
   The sidebar is fixed; the main column is pushed over with a margin so the
   sidebar never scrolls with the content.
============================================================================= */

.app-shell {
    min-height: 100vh;
}

.app-main {
    margin-left: var(--tameer-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .2s ease;
}

.app-shell.sidebar-collapsed .app-main {
    margin-left: var(--tameer-sidebar-rail);
}

.app-content {
    flex: 1 1 auto;
    padding: 1.5rem;
}

/* =============================================================================
   Sidebar
============================================================================= */

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--tameer-sidebar-width);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    background-color: var(--tameer-sidebar-bg);
    color: var(--tameer-sidebar-ink);
    transition: width .2s ease, transform .2s ease;
    overflow: hidden;
}

.app-shell.sidebar-collapsed .app-sidebar {
    width: var(--tameer-sidebar-rail);
}

.sidebar-header {
    height: var(--tameer-topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, .16);
    flex: 0 0 auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand-mark {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: .5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--tameer-primary);
    color: #fff;
    font-size: 1.15rem;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: .2px;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .5rem 0 1rem;
}

/* Slim scrollbar so the dark rail does not get a bright native bar. */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: rgba(148, 163, 184, .3);
    border-radius: 3px;
}

.sidebar-heading {
    padding: 1rem 1.15rem .35rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--tameer-sidebar-ink-dim);
    white-space: nowrap;
}

.app-sidebar .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .58rem 1.15rem;
    color: var(--tameer-sidebar-ink);
    font-size: .9rem;
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.app-sidebar .nav-link > i {
    flex: 0 0 auto;
    width: 1.25rem;
    font-size: 1.05rem;
    text-align: center;
}

.app-sidebar .nav-link:hover,
.app-sidebar .nav-link:focus-visible {
    color: #fff;
    background-color: rgba(148, 163, 184, .12);
}

.app-sidebar .nav-link.active {
    color: #fff;
    background-color: rgba(180, 83, 9, .22);
    border-left-color: var(--tameer-primary);
    font-weight: 600;
}

.sidebar-footer {
    flex: 0 0 auto;
    padding: .5rem;
    border-top: 1px solid rgba(148, 163, 184, .16);
}

.sidebar-collapse-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .5rem .8rem;
    background: transparent;
    border: 0;
    border-radius: .4rem;
    color: var(--tameer-sidebar-ink-dim);
    font-size: .85rem;
    white-space: nowrap;
}

.sidebar-collapse-btn:hover {
    background-color: rgba(148, 163, 184, .12);
    color: #fff;
}

.sidebar-collapse-btn > i {
    width: 1.25rem;
    text-align: center;
    transition: transform .2s ease;
}

.app-shell.sidebar-collapsed .sidebar-collapse-btn > i {
    transform: rotate(180deg);
}

/* ---- Collapsed (icon rail) state -------------------------------------- */

.app-shell.sidebar-collapsed .nav-text,
.app-shell.sidebar-collapsed .sidebar-brand-text,
.app-shell.sidebar-collapsed .sidebar-heading > span {
    display: none;
}

.app-shell.sidebar-collapsed .app-sidebar .nav-link,
.app-shell.sidebar-collapsed .sidebar-collapse-btn {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.app-shell.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

/* Group separator stands in for the hidden heading text. */
.app-shell.sidebar-collapsed .sidebar-heading {
    padding: .5rem 1rem;
    margin: .25rem 0;
    border-top: 1px solid rgba(148, 163, 184, .16);
}

/* CSS-only tooltip: only rendered while collapsed, so it never duplicates a
   visible label and needs no JS state juggling. */
.app-shell.sidebar-collapsed .app-sidebar .nav-link::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: .3rem .6rem;
    border-radius: .35rem;
    background-color: #1e293b;
    color: #fff;
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 .25rem .75rem rgba(15, 23, 42, .35);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .12s ease;
    z-index: 1050;
}

.app-shell.sidebar-collapsed .app-sidebar .nav-link:hover::after,
.app-shell.sidebar-collapsed .app-sidebar .nav-link:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background-color: rgba(15, 23, 42, .5);
}

/* =============================================================================
   Top bar
============================================================================= */

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--tameer-topbar-height);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1rem;
    background-color: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: .45rem;
    background: transparent;
    color: var(--tameer-ink);
    font-size: 1.3rem;
}

.topbar-btn:hover { background-color: var(--tameer-surface); }

.topbar-title {
    font-size: 1.02rem;
    font-weight: 600;
    margin: 0;
    margin-right: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Project switcher ---- */

.project-switcher-btn {
    display: inline-flex;
    align-items: center;
    max-width: 300px;
    border: 1px solid #e2e8f0;
    background-color: #fff;
    font-size: .875rem;
    font-weight: 500;
    color: var(--tameer-ink);
}

.project-switcher-btn:hover { background-color: var(--tameer-surface); }

.project-switcher-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-switcher-menu {
    width: min(380px, calc(100vw - 2rem));
    padding: 0;
    overflow: hidden;
}

.project-switcher-search {
    padding: .65rem;
    border-bottom: 1px solid #e2e8f0;
    background-color: #f8fafc;
}

.project-switcher-results {
    max-height: 340px;
    overflow-y: auto;
    padding: .35rem 0;
}

.project-switcher-results .dropdown-header {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--tameer-muted);
    padding: .5rem .9rem .25rem;
}

.project-option {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: .45rem .9rem;
    font-size: .875rem;
    line-height: 1.3;
}

.project-option:hover,
.project-option:focus-visible { background-color: var(--tameer-surface); }

.project-option.selected {
    background-color: rgba(180, 83, 9, .1);
    font-weight: 600;
}

.project-option .project-option-meta {
    display: block;
    font-size: .75rem;
    font-weight: 400;
    color: var(--tameer-muted);
}

/* ---- User menu ---- */

.topbar-user-btn {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    border: 0;
    background: transparent;
    padding: .25rem .5rem;
}

.topbar-user-btn:hover { background-color: var(--tameer-surface); }

.topbar-avatar {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--tameer-primary);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
}

.topbar-user-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
}

.topbar-user-name {
    font-size: .85rem;
    font-weight: 600;
    color: var(--tameer-ink);
}

.topbar-user-role {
    font-size: .72rem;
    color: var(--tameer-muted);
}

/* =============================================================================
   Global loading overlay
============================================================================= */

.app-loading {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(15, 23, 42, .35);
}

.app-loading[hidden] { display: none; }

.app-loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    padding: 1.5rem 2rem;
    border-radius: .6rem;
    background-color: #fff;
    box-shadow: 0 1rem 2rem rgba(15, 23, 42, .25);
}

.app-loading-text {
    font-size: .875rem;
    color: var(--tameer-muted);
}

/* =============================================================================
   Toasts
============================================================================= */

.toast-container { z-index: 2100; }

.app-toast {
    border: 0;
    border-left: 4px solid var(--bs-secondary);
    box-shadow: 0 .5rem 1.25rem rgba(15, 23, 42, .2);
}

.app-toast.toast-success { border-left-color: #198754; }
.app-toast.toast-danger  { border-left-color: #dc3545; }
.app-toast.toast-warning { border-left-color: #ffc107; }
.app-toast.toast-info    { border-left-color: #0dcaf0; }

.app-toast .toast-icon { font-size: 1.1rem; }
.app-toast.toast-success .toast-icon { color: #198754; }
.app-toast.toast-danger  .toast-icon { color: #dc3545; }
.app-toast.toast-warning .toast-icon { color: #b8860b; }
.app-toast.toast-info    .toast-icon { color: #0aa2c0; }

/* =============================================================================
   Mobile: sidebar becomes an icon rail, expanding over the content on toggle
============================================================================= */

@media (max-width: 991.98px) {

    .app-main,
    .app-shell.sidebar-collapsed .app-main {
        margin-left: var(--tameer-sidebar-rail);
    }

    /* Default on small screens is the icon rail, regardless of desktop state. */
    .app-sidebar { width: var(--tameer-sidebar-rail); }

    .app-shell .nav-text,
    .app-shell .sidebar-brand-text,
    .app-shell .sidebar-heading > span {
        display: none;
    }

    .app-shell .app-sidebar .nav-link,
    .app-shell .sidebar-collapse-btn {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    .app-shell .sidebar-header {
        justify-content: center;
        padding: 0;
    }

    .app-shell .sidebar-heading {
        padding: .5rem 1rem;
        margin: .25rem 0;
        border-top: 1px solid rgba(148, 163, 184, .16);
    }

    /* Toggled open: expand over the content rather than pushing it. */
    .app-shell.sidebar-mobile-open .app-sidebar {
        width: var(--tameer-sidebar-width);
        box-shadow: 0 0 2rem rgba(15, 23, 42, .5);
    }

    .app-shell.sidebar-mobile-open .nav-text,
    .app-shell.sidebar-mobile-open .sidebar-brand-text,
    .app-shell.sidebar-mobile-open .sidebar-heading > span {
        display: inline;
    }

    .app-shell.sidebar-mobile-open .app-sidebar .nav-link,
    .app-shell.sidebar-mobile-open .sidebar-collapse-btn {
        justify-content: flex-start;
        padding-left: 1.15rem;
        padding-right: 1.15rem;
    }

    .app-shell.sidebar-mobile-open .sidebar-header {
        justify-content: flex-start;
        padding: 0 1rem;
    }

    .app-shell.sidebar-mobile-open .sidebar-heading {
        padding: 1rem 1.15rem .35rem;
        margin: 0;
        border-top: 0;
    }

    /* Rail tooltips would collide with the expanded panel. */
    .app-shell.sidebar-mobile-open .app-sidebar .nav-link::after { content: none; }

    .app-sidebar .nav-link::after {
        content: attr(data-label);
        position: absolute;
        left: calc(100% + 8px);
        top: 50%;
        transform: translateY(-50%);
        padding: .3rem .6rem;
        border-radius: .35rem;
        background-color: #1e293b;
        color: #fff;
        font-size: .8rem;
        white-space: nowrap;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        z-index: 1050;
    }

    .app-sidebar .nav-link:hover::after { opacity: 1; visibility: visible; }

    /* The collapse button is desktop-only; the top-bar hamburger drives mobile. */
    .sidebar-footer { display: none; }

    .app-content { padding: 1rem; }

    .topbar-title { display: none; }

    .topbar-user-text { display: none; }

    .project-switcher-btn { max-width: 190px; }
}

@media (min-width: 992px) {
    /* The backdrop only belongs to the mobile overlay. */
    .sidebar-backdrop { display: none !important; }
}
