/* ==========================================================
   A³ Workforce Suite
   Office aesthetic authenticated layout
   ========================================================== */

:root {
    --app-primary: #2563eb;
    --app-primary-dark: color-mix(in srgb, var(--app-primary), black 18%);
    --app-primary-deep: color-mix(in srgb, var(--app-primary), black 36%);

    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f3f6fa;
    --surface-glass: rgba(255,255,255,.92);
    --text: #111827;
    --text-muted: #64748b;
    --border: rgba(15,23,42,.12);
    --shadow-sm: 0 6px 18px rgba(15,23,42,.05);
    --shadow-md: 0 14px 34px rgba(15,23,42,.08);
    --shadow-lg: 0 24px 56px rgba(15,23,42,.12);
}

html.app-theme-dark {
    --bg: #0b1220;
    --surface: #111827;
    --surface-2: #182132;
    --surface-glass: rgba(17,24,39,.94);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(148,163,184,.22);
    --shadow-sm: 0 8px 20px rgba(0,0,0,.22);
    --shadow-md: 0 18px 40px rgba(0,0,0,.28);
    --shadow-lg: 0 28px 64px rgba(0,0,0,.34);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

html.app-theme-light body {
    background: linear-gradient(180deg, #f8fafc 0%, #f5f7fb 100%);
}

html.app-theme-dark body {
    background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
}

.app-main {
    width: min(1440px, calc(100% - 40px));
    margin: 24px auto 0;
    padding: 0 0 44px;
}

.a3-header {
    position: sticky;
    top: 0;
    z-index: 2000;
    width: 100%;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}

.a3-header-aura {
    display: none;
}

.a3-header-inner {
    width: min(1520px, calc(100% - 40px));
    min-height: 82px;
    display: flex;
    align-items: center;
    gap: 28px;
    margin: 0 auto;
}

.a3-brand {
    min-width: 290px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.a3-brand-logo,
.a3-brand-mark {
    width: 54px !important;
    height: 54px !important;
    min-width: 54px !important;
    max-width: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    object-fit: contain !important;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--app-primary) 18%, var(--border));
    border-radius: 16px;
    padding: 7px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    color: var(--app-primary);
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: -.05em;
}

.a3-brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.a3-brand-text strong {
    max-width: 260px;
    overflow: hidden;
    color: var(--text);
    font-size: .98rem;
    font-weight: 800;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.a3-brand-text small {
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.a3-nav-panel {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 24px;
    min-width: 0;
}

.a3-nav {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.a3-nav-link {
    position: relative;
    min-height: 58px;
    display: inline-flex;
    align-items: center;
    border: 0;
    background: transparent;
    color: var(--text);
    padding: 0 14px;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    opacity: .92;
}

.a3-nav-link::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 8px;
    height: 2px;
    border-radius: 999px;
    background: var(--app-primary);
    opacity: 0;
    transform: scaleX(.5);
    transition: .18s ease;
}

.a3-nav-link:hover,
.a3-dropdown.open > .a3-nav-link {
    color: var(--app-primary);
    opacity: 1;
}

.a3-nav-link:hover::after,
.a3-dropdown.open > .a3-nav-link::after {
    opacity: 1;
    transform: scaleX(1);
}

.a3-dropdown {
    position: relative;
}

.a3-dropdown-toggle::before {
    content: "";
    width: 7px;
    height: 7px;
    order: 2;
    margin-left: 5px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    opacity: .68;
}

.a3-mega-menu {
    position: fixed;
    top: 82px;
    left: 50%;
    z-index: 6000;
    width: min(920px, calc(100vw - 44px));
    padding: 22px 24px 24px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface-glass);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px);
    transform: translate(-50%, 12px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: .18s ease;
}

.a3-dropdown.open > .a3-mega-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

.a3-mega-menu-right {
    left: auto;
    right: 24px;
    transform: translate(0, 12px);
}

.a3-dropdown.open > .a3-mega-menu-right {
    transform: translate(0, 0);
}

.a3-mega-head {
    margin-bottom: 18px;
}

.a3-mega-head strong {
    display: block;
    color: var(--text);
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.a3-mega-head small {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 500;
}

.a3-mega-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.a3-mega-grid a {
    min-height: 112px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface-2) 92%, var(--surface));
    transition: .18s ease;
}

.a3-mega-grid a:hover {
    border-color: color-mix(in srgb, var(--app-primary) 28%, var(--border));
    background: color-mix(in srgb, var(--app-primary) 6%, var(--surface));
}

.a3-mega-grid span {
    color: var(--text);
    font-size: .92rem;
    font-weight: 800;
}

.a3-mega-grid small {
    max-width: 180px;
    color: var(--text-muted);
    font-size: .78rem;
    line-height: 1.55;
}

.a3-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
}

.a3-search-wrap,
.a3-user {
    position: relative;
}

.a3-search-trigger {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: .18s ease;
    box-shadow: var(--shadow-sm);
}

.a3-search-trigger:hover {
    border-color: color-mix(in srgb, var(--app-primary) 28%, var(--border));
    background: color-mix(in srgb, var(--app-primary) 6%, var(--surface));
}

.a3-search-trigger span {
    color: var(--app-primary);
    font-size: 1.2rem;
    line-height: 1;
}

.a3-search-trigger strong {
    display: none;
}

.a3-search-results {
    position: fixed;
    top: 78px;
    right: 88px;
    z-index: 6500;
    width: min(420px, calc(100vw - 34px));
    max-height: min(620px, calc(100vh - 128px));
    overflow: auto;
    display: none;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface-glass);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px);
}

.a3-search-results.is-visible {
    display: block;
}

.a3-search-input {
    width: 100%;
    min-height: 46px;
    border: 1px solid color-mix(in srgb, var(--border) 78%, #64748b 22%);
    border-radius: 14px;
    outline: none;
    padding: 0 14px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
}

.a3-search-list {
    display: grid;
    gap: 6px;
    margin-top: 10px;
}

.a3-search-list a {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 13px;
    border-radius: 12px;
    color: var(--text);
    background: transparent;
}

.a3-search-list a:hover {
    background: color-mix(in srgb, var(--app-primary) 6%, var(--surface));
}

.a3-search-list span {
    font-weight: 800;
}

.a3-search-list small {
    color: var(--text-muted);
}

.a3-user-btn {
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    gap: 11px;
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.a3-user-avatar {
    width: 42px;
    height: 42px;
    position: relative;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--app-primary) 18%, var(--border));
    border-radius: 50%;
    background: var(--surface);
    color: var(--app-primary);
    font-weight: 800;
}

.a3-user-avatar::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 2px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 3px var(--surface);
}

.a3-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.a3-user-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
}

.a3-user-copy strong {
    max-width: 130px;
    overflow: hidden;
    color: var(--text);
    font-size: .88rem;
    font-weight: 800;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.a3-user-copy small {
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 650;
}

.a3-user-menu {
    position: fixed;
    top: 78px;
    right: 24px;
    z-index: 6500;
    width: 240px;
    display: none;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-glass);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px);
}

.a3-user-menu.is-visible {
    display: grid;
    gap: 4px;
}

.a3-user-menu a,
.a3-user-menu button {
    width: 100%;
    border: 0;
    display: flex;
    padding: 11px 12px;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    text-align: left;
    font-size: .84rem;
    font-weight: 750;
    cursor: pointer;
}

.a3-user-menu a:hover,
.a3-user-menu button:hover {
    background: color-mix(in srgb, var(--app-primary) 6%, var(--surface));
}

.a3-user-menu button {
    color: #ef4444;
}

.public-navbar {
    width: min(1180px, calc(100% - 32px));
    margin: 18px auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    background: var(--surface-glass);
    box-shadow: var(--shadow-md);
}

.public-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 850;
}

.public-brand span {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--app-primary);
}

.public-navbar nav {
    display: flex;
    gap: 8px;
}

.public-navbar nav a {
    padding: 10px 14px;
    font-weight: 750;
}

.public-cta {
    color: #fff;
    background: var(--app-primary);
}

.card,
.modal-content {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.form-control,
.form-select {
    min-height: 44px;
    border: 1px solid color-mix(in srgb, var(--border) 78%, #64748b 22%);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
}

.form-control:focus,
.form-select:focus {
    border-color: color-mix(in srgb, var(--app-primary) 42%, var(--border));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-primary) 10%, transparent);
}

.btn-primary {
    border: 0;
    background: var(--app-primary);
}

.a3-mobile-toggle {
    position: relative;
    width: 46px;
    height: 46px;
    display: none;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.a3-mobile-toggle span {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 2px;
    display: block;
    background: var(--text);
    margin: 0;
    transform: translate(-50%, -50%);
    transition: .18s ease;
}

.a3-mobile-toggle span:nth-child(1) {
    transform: translate(-50%, calc(-50% - 7px));
}

.a3-mobile-toggle span:nth-child(3) {
    transform: translate(-50%, calc(-50% + 7px));
}

.a3-mobile-toggle.is-active span:nth-child(1) {
    transform: translate(-50%, -50%) rotate(45deg);
}

.a3-mobile-toggle.is-active span:nth-child(2) {
    opacity: 0;
}

.a3-mobile-toggle.is-active span:nth-child(3) {
    transform: translate(-50%, -50%) rotate(-45deg);
}

@media (max-width: 1320px) {
    .a3-header-inner {
        width: min(100% - 28px, 1480px);
        gap: 18px;
    }

    .a3-brand {
        min-width: 240px;
    }

    .a3-user-copy {
        display: none;
    }
}

@media (max-width: 1080px) {
    .a3-header-inner {
        position: relative;
        min-height: 76px;
        flex-wrap: nowrap;
        padding: 10px 0;
    }

    .a3-brand {
        flex: 1;
        min-width: 0;
    }

    .a3-mobile-toggle {
        display: grid;
    }

    .a3-nav-panel {
        position: absolute;
        top: calc(100% + 9px);
        right: 0;
        left: 0;
        z-index: 2100;
        width: auto;
        max-height: calc(100vh - 104px);
        display: none;
        overflow-x: hidden;
        overflow-y: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: 20px;
        background: color-mix(in srgb, var(--surface) 97%, transparent);
        box-shadow: var(--shadow-lg);
        backdrop-filter: blur(18px);
        overscroll-behavior: contain;
    }

    .a3-nav-panel.is-open {
        display: flex;
    }

    .a3-nav {
        width: 100%;
        flex: none;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
    }

    .a3-dropdown {
        width: 100%;
        min-width: 0;
    }

    .a3-nav-link {
        width: 100%;
        min-height: 48px;
        justify-content: flex-start;
        padding: 0 12px;
    }

    .a3-nav-link::after {
        display: none;
    }

    .a3-mega-menu,
    .a3-mega-menu-right {
        position: static;
        width: 100%;
        display: none;
        transform: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        box-shadow: none;
        margin-top: 8px;
    }

    .a3-dropdown.open > .a3-mega-menu,
    .a3-dropdown.open > .a3-mega-menu-right {
        display: block;
        transform: none;
    }

    .a3-mega-grid {
        grid-template-columns: 1fr;
    }

    .a3-mega-grid a {
        min-height: auto;
    }

    .a3-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
        margin-left: 0;
        padding-top: 14px;
        border-top: 1px solid var(--border);
    }

    .a3-search-wrap,
    .a3-user {
        width: 100%;
    }

    .a3-search-trigger {
        width: 100%;
        min-width: 100%;
        justify-content: flex-start;
        padding: 0 14px;
        border-radius: 12px;
    }

    .a3-search-trigger strong {
        display: inline;
    }

    .a3-user-btn {
        width: 100%;
        justify-content: flex-start;
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 0 14px;
    }

    .a3-user-copy {
        display: flex;
    }

    .a3-search-results,
    .a3-user-menu {
        position: static;
        width: 100%;
        max-height: 360px;
    }

    .a3-user-menu.is-visible {
        display: grid;
    }
}

@media (max-width: 640px) {
    .app-main {
        width: calc(100% - 20px);
        margin-top: 20px;
    }

    .a3-header-inner {
        width: calc(100% - 20px);
    }

    .a3-brand-logo,
    .a3-brand-mark {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        max-width: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
    }

    .a3-brand-text strong {
        max-width: 180px;
    }

    .a3-brand-text small {
        font-size: .64rem;
    }

    .public-navbar {
        flex-direction: column;
        align-items: stretch;
    }

    .public-navbar nav {
        flex-wrap: wrap;
    }
}
