/* Dsmart Result System — mobile-first app shell */

:root {
    --app-topbar-h: 56px;
    --app-bottom-nav-h: 64px;
    --app-sidebar-w: 280px;
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --ui-zoom: 1;
}

body {
    background: #f1f5f9;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
}

body.app-authenticated {
    overflow: hidden;
}

/* ── App shell ── */
.app-viewport {
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    background: #e2e8f0;
    position: relative;
}

.app-shell {
    display: flex;
    width: calc(100vw / var(--ui-zoom));
    height: calc(100dvh / var(--ui-zoom));
    zoom: var(--ui-zoom);
    overflow: hidden;
}

@supports not (zoom: 1) {
    .app-shell {
        zoom: unset;
        transform: scale(var(--ui-zoom));
        transform-origin: top left;
        width: calc(100vw / var(--ui-zoom));
        min-height: calc(100dvh / var(--ui-zoom));
    }

    .app-viewport {
        height: 100dvh;
    }
}

/* ── Auth pages ── */
.auth-wrapper {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    padding-bottom: calc(1.25rem + var(--app-safe-bottom));
    background: linear-gradient(145deg, var(--ds-primary) 0%, var(--ds-secondary) 55%, #1e40af 100%);
    position: relative;
    overflow: hidden;
}

.auth-bg-shape {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.12;
    background: #fff;
}

.auth-bg-shape-1 {
    width: 320px;
    height: 320px;
    top: -80px;
    right: -60px;
    animation: authFloat 8s ease-in-out infinite;
}

.auth-bg-shape-2 {
    width: 240px;
    height: 240px;
    bottom: -60px;
    left: -40px;
    animation: authFloat 10s ease-in-out infinite reverse;
}

@keyframes authFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(12px, -16px) scale(1.05); }
}

@keyframes authSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.auth-animate-in {
    animation: authSlideUp 0.5s ease-out;
}

.auth-card {
    background: #fff;
    border-radius: 1.25rem;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    max-width: 420px;
    width: 100%;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.auth-header {
    padding: 2rem 2rem 1.25rem;
    text-align: center;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
    border-bottom: 1px solid #e2e8f0;
}

.auth-logo-ring {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #eff6ff, #fff);
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(30, 58, 138, 0.12);
    animation: authFloat 6s ease-in-out infinite;
}

.auth-logo-ring img {
    height: 48px;
    width: auto;
    max-width: 56px;
    object-fit: contain;
}

.auth-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--ds-primary);
    margin: 0 0 0.35rem;
    letter-spacing: -0.02em;
}

.auth-tagline {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
}

.auth-body {
    padding: 1.5rem 2rem 1.75rem;
}

.auth-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.4rem;
}

.auth-label i {
    color: var(--ds-primary);
    font-size: 0.85rem;
}

.auth-input-wrap {
    position: relative;
}

.auth-input-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 1rem;
    pointer-events: none;
    z-index: 2;
}

.auth-input {
    padding: 0.65rem 0.85rem 0.65rem 2.5rem;
    border-radius: 0.65rem;
    border: 1px solid #e2e8f0;
    font-size: 0.95rem;
    min-height: 48px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-input:focus {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.auth-input-wrap .auth-input {
    padding-right: 2.75rem;
}

.auth-toggle-pw {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #64748b;
    padding: 0.35rem 0.5rem;
    border-radius: 0.35rem;
    line-height: 1;
    z-index: 2;
}

.auth-toggle-pw:hover {
    color: var(--ds-primary);
    background: #f1f5f9;
}

.auth-submit-btn {
    font-weight: 600;
    font-size: 1rem;
    min-height: 50px;
    border-radius: 0.65rem;
    box-shadow: 0 4px 14px rgba(30, 58, 138, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(30, 58, 138, 0.3);
}

.auth-alert {
    font-size: 0.875rem;
    border-radius: 0.65rem;
    margin-bottom: 1rem;
}

/* Student result checker on login card */
.auth-student-check {
    margin-top: 1.5rem;
    padding: 1rem 1.1rem;
    border-radius: 0.75rem;
    background: linear-gradient(145deg, #eff6ff 0%, #f0fdf4 100%);
    border: 1px solid #bfdbfe;
    text-align: center;
}

.auth-student-check-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ds-primary);
    margin-bottom: 0.5rem;
}

.auth-student-check-label .bi {
    font-size: 0.95rem;
    color: var(--ds-secondary);
}

.auth-student-check-text {
    font-size: 0.875rem;
    color: #334155;
    line-height: 1.45;
    margin-bottom: 0.85rem !important;
}

.auth-student-check-text strong {
    color: #0f172a;
}

.auth-student-check-btn {
    font-weight: 700;
    font-size: 0.95rem;
    min-height: 46px;
    border-radius: 0.6rem;
    border: none;
    color: #fff !important;
    background: linear-gradient(135deg, var(--ds-secondary) 0%, var(--ds-primary) 100%);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-student-check-btn:hover,
.auth-student-check-btn:focus {
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.auth-footer {
    text-align: center;
    padding: 0 1.5rem 1.25rem;
    border-top: 1px solid #f1f5f9;
    padding-top: 1rem;
}

.developer-credit { font-size: 0.75rem; color: #94a3b8; }

@media (max-width: 575.98px) {
    .auth-body { padding: 1.25rem 1.35rem 1.5rem; }
    .auth-header { padding: 1.5rem 1.35rem 1rem; }
    .auth-title { font-size: 1.2rem; }
}

.btn-dsmart {
    background: var(--ds-primary);
    border-color: var(--ds-primary);
    color: #fff;
    min-height: 48px;
}

.btn-dsmart:hover,
.btn-dsmart:focus {
    background: var(--ds-secondary);
    border-color: var(--ds-secondary);
    color: #fff;
}

.app-sidebar {
    width: var(--app-sidebar-w);
    flex-shrink: 0;
    height: calc(100dvh / var(--ui-zoom));
    max-height: calc(100dvh / var(--ui-zoom));
    background: linear-gradient(180deg, var(--ds-primary) 0%, #152a5e 100%);
    color: #fff;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
    z-index: 1035;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.app-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.08);
}

.app-sidebar-logo {
    flex-shrink: 0;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px;
}

.app-sidebar-title {
    font-size: 0.9rem;
    line-height: 1.3;
    color: #fff;
}

.app-sidebar-subtitle {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.75rem;
}

.app-sidebar-nav {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.app-sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.app-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 4px;
}

.app-sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.65);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.06);
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    margin: 0.2rem 0.65rem;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    border-radius: 0.6rem;
    font-size: 0.92rem;
    font-weight: 500;
    min-height: 44px;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.app-offcanvas.app-offcanvas {
    width: min(300px, 88vw);
}

.app-offcanvas .offcanvas-header {
    background: #f8fafc;
}

.app-offcanvas .app-nav-link {
    color: #334155;
    margin: 0.15rem 0.65rem;
    font-weight: 500;
}

.app-nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.app-sidebar .app-nav-link:hover {
    background: rgba(255, 255, 255, 0.14);
}

.app-sidebar .app-nav-link.active {
    background: #fff;
    color: var(--ds-primary);
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.app-offcanvas .app-nav-link:hover {
    background: #eef2ff;
    color: var(--ds-primary);
}

.app-offcanvas .app-nav-link.active {
    background: var(--ds-primary);
    color: #fff;
    font-weight: 600;
}

.app-nav-link i {
    font-size: 1.15rem;
    width: 1.4rem;
    text-align: center;
    flex-shrink: 0;
}

.app-nav-link span {
    line-height: 1.25;
}

.app-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    height: calc(100dvh / var(--ui-zoom));
    overflow: hidden;
    background: #e2e8f0;
}

.app-topbar {
    height: var(--app-topbar-h);
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    gap: 0.75rem;
    z-index: 1020;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.app-page-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

.app-topbar-user {
    max-width: 120px;
}

.app-zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 2rem;
    padding: 0.2rem 0.45rem;
}

.app-zoom-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: var(--ds-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: transform 0.12s ease, background 0.12s ease;
    padding: 0;
    line-height: 1;
}

.app-zoom-btn:hover {
    background: #eef2ff;
}

.app-zoom-btn:active {
    transform: scale(0.92);
}

.app-zoom-reset {
    width: auto;
    border-radius: 1rem;
    padding: 0 0.5rem;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 32px;
}

.app-zoom-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #475569;
    min-width: 38px;
    text-align: center;
}

.app-menu-btn { min-width: 44px; min-height: 44px; }

.app-content {
    flex: 1;
    min-height: 0;
    padding: 0.85rem;
    padding-bottom: calc(0.85rem + var(--app-bottom-nav-h) + var(--app-safe-bottom));
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.app-content-inner {
    background: #fff;
    border-radius: 0.85rem;
    border: 1px solid #e2e8f0;
    padding: 1.15rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

@media (min-width: 992px) {
    .app-content {
        padding: 1.15rem 1.25rem;
        padding-bottom: 1.15rem;
    }

    .app-content-inner {
        padding: 1.35rem 1.5rem;
    }
}

@media (max-width: 575.98px) {
    .app-zoom-reset {
        display: none;
    }

    .app-topbar-user {
        display: none !important;
    }
}

.app-footer {
    flex-shrink: 0;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

/* Mobile bottom nav */
.app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--app-bottom-nav-h) + var(--app-safe-bottom));
    padding-bottom: var(--app-safe-bottom);
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    z-index: 1030;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

.app-bottom-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    color: #64748b;
    text-decoration: none;
    font-size: 0.65rem;
    border: none;
    background: none;
    min-height: 44px;
    padding: 0.35rem 0.25rem;
}

.app-bottom-link i { font-size: 1.25rem; }

.app-bottom-link.active,
.app-bottom-link:hover {
    color: var(--ds-primary);
}

/* Cards & tables */
.stat-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.table-responsive {
    border-radius: 0.75rem;
    background: #fff;
    border: 1px solid #e2e8f0;
}

.card {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    background: #fff;
}

/* Touch-friendly forms on mobile */
@media (max-width: 991.98px) {
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px;
    }

    .btn {
        min-height: 44px;
    }
}

/* Sticky save on mobile (above bottom nav) */
@media (max-width: 991.98px) {
    .sticky-save-mobile {
        position: sticky;
        bottom: calc(var(--app-bottom-nav-h) + var(--app-safe-bottom) + 0.5rem);
        z-index: 1010;
    }
}

/* Standalone PWA mode */
@media (display-mode: standalone) {
    .app-topbar {
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(var(--app-topbar-h) + env(safe-area-inset-top, 0px));
    }
}

/* ── Topbar user menu ── */
.app-user-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 2rem;
    padding: 0.2rem 0.55rem 0.2rem 0.2rem;
    min-height: 40px;
    color: #0f172a;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-user-menu-btn:hover,
.app-user-menu-btn:focus,
.app-user-menu-btn.show {
    background: #fff;
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    color: #0f172a;
}

.app-user-menu-btn::after {
    margin-left: 0;
    font-size: 0.65rem;
    color: #64748b;
}

.app-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ds-primary) 0%, var(--ds-secondary) 100%);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.app-user-name {
    max-width: 120px;
    font-size: 0.82rem;
    font-weight: 600;
}

.app-user-dropdown {
    min-width: 220px;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.35rem;
}

.app-user-dropdown-head {
    padding: 0.55rem 0.75rem 0.45rem;
    max-width: 240px;
}

.app-user-dropdown-item {
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
}

.app-user-dropdown-item:hover {
    background: #f1f5f9;
}

@media (max-width: 575.98px) {
    .app-topbar-user {
        display: none !important;
    }

    .app-user-name {
        display: none !important;
    }
}

/* ── My Profile page ── */
.acct-profile-page {
    max-width: 960px;
    margin: 0 auto;
}

.acct-animate-in {
    animation: acctFadeUp 0.45s ease both;
}

.acct-delay-1 { animation-delay: 0.06s; }
.acct-delay-2 { animation-delay: 0.12s; }
.acct-delay-3 { animation-delay: 0.18s; }

@keyframes acctFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.acct-profile-hero {
    position: relative;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid #dbeafe;
    background: #fff;
    margin-bottom: 0.25rem;
}

.acct-profile-hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(125deg, rgba(30, 58, 138, 0.08) 0%, rgba(37, 99, 235, 0.12) 45%, rgba(34, 197, 94, 0.06) 100%);
}

.acct-profile-hero-body {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.35rem;
    flex-wrap: wrap;
}

.acct-profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--ds-primary), var(--ds-secondary));
    color: #fff;
    font-size: 1.35rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(30, 58, 138, 0.25);
    flex-shrink: 0;
}

.acct-profile-name {
    font-size: 1.35rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
}

.acct-profile-email {
    color: #64748b;
    font-size: 0.9rem;
    margin: 0;
}

.acct-profile-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.55rem;
    border-radius: 2rem;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.acct-profile-badge-muted {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.acct-profile-badge-role {
    background: #ecfdf5;
    color: #047857;
    border-color: #bbf7d0;
}

.acct-profile-meta {
    margin-left: auto;
    text-align: right;
}

.acct-profile-meta-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    font-weight: 700;
}

.acct-profile-meta-value {
    font-size: 0.82rem;
    color: #334155;
    font-weight: 600;
}

.acct-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.85rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

.acct-card-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.15rem;
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
    font-weight: 700;
    color: #0f172a;
    font-size: 0.92rem;
}

.acct-card-head i {
    color: var(--ds-primary);
    font-size: 1rem;
}

.acct-card-body {
    padding: 1.15rem;
}

.acct-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.acct-label i {
    color: var(--ds-primary);
    font-size: 0.85rem;
}

.acct-input {
    border-radius: 0.55rem;
    border-color: #cbd5e1;
    padding: 0.55rem 0.75rem;
}

.acct-input:focus {
    border-color: var(--ds-secondary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

.acct-pw-wrap {
    position: relative;
}

.acct-pw-input {
    padding-right: 2.75rem;
}

.acct-pw-toggle {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #64748b;
    width: 36px;
    height: 36px;
    border-radius: 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.acct-pw-toggle:hover {
    background: #f1f5f9;
    color: var(--ds-primary);
}

.acct-tip-icon {
    width: 42px;
    height: 42px;
    border-radius: 0.65rem;
    background: #eef2ff;
    color: var(--ds-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.acct-profile-tips {
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}
