/* Header strip: logged-in user name + logout (main app) */
.app-header-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #1e293b;
    color: #f1f5f9;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-header-nav-toggle {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: rgba(248, 250, 252, 0.08);
    color: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.app-header-nav-toggle:hover {
    background: rgba(248, 250, 252, 0.12);
    border-color: rgba(148, 163, 184, 0.55);
}

.app-header-nav-toggle:active {
    background: rgba(248, 250, 252, 0.16);
}

.app-header-user {
    font-weight: 600;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header-logout {
    padding: 8px 14px;
    background: transparent;
    color: #94a3b8;
    border: 1px solid #475569;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.app-header-logout:hover {
    background: rgba(248, 250, 252, 0.08);
    color: #f8fafc;
    border-color: #64748b;
}

.app-header-logout:active {
    background: rgba(248, 250, 252, 0.12);
}

/* Global navigation drawer (pages) */
.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 80;
}

.nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    width: min(320px, 88vw);
    background: white;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 90;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.nav-open {
    overflow: hidden;
    overscroll-behavior: none;
}

body.nav-open .nav-overlay {
    opacity: 1;
    pointer-events: auto;
}

body.nav-open .nav-drawer {
    transform: translateX(0);
}

.chat-page.nav-open .app-container,
.chat-page.nav-open .app-header-strip {
    pointer-events: none;
}

.chat-page.nav-open .nav-overlay,
.chat-page.nav-open .nav-drawer,
.chat-page.nav-open .nav-drawer * {
    pointer-events: auto;
}

.chat-page.nav-open .nav-overlay {
    z-index: 110;
}

.chat-page.nav-open .nav-drawer {
    z-index: 120;
}

.nav-drawer-header {
    padding: 18px 16px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.nav-drawer-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.nav-links {
    padding: 12px;
    padding-bottom: max(28px, calc(env(safe-area-inset-bottom, 0px) + 20px));
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    letter-spacing: 0.02em;
    padding: 10px 0 8px;
    border-bottom: 1px solid #e2e8f0;
    margin: 0 8px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: #0f172a;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
    background: #f3f4f6;
}

.nav-link.active {
    background: #eff6ff;
    color: #2563eb;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-header {
    margin-bottom: 28px;
    text-align: center;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
}

.login-header p {
    font-size: 14px;
    color: #64748b;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form label {
    font-size: 14px;
    font-weight: 500;
    color: #334155;
}

.login-form input {
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-form input::placeholder {
    color: #94a3b8;
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 44px;
    width: 100%;
    box-sizing: border-box;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.password-toggle:hover {
    color: #334155;
    background: rgba(0, 0, 0, 0.05);
}

.password-toggle:focus {
    outline: none;
    color: #2563eb;
}

.password-toggle .icon-eye-closed {
    display: none;
}

.password-toggle[aria-pressed="true"] .icon-eye-open {
    display: none;
}

.password-toggle[aria-pressed="true"] .icon-eye-closed {
    display: block;
}

.login-error {
    font-size: 13px;
    color: #dc2626;
    min-height: 20px;
}

.login-submit {
    padding: 12px 20px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}

.login-submit:hover {
    background: #1d4ed8;
}

.login-submit:active {
    background: #1e40af;
}

.login-submit:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}
