/* ============================================
   eXalt Dashboard — Design System
   ============================================ */

:root {
    --exalt-blue: #007FFF;
    --exalt-blue-dark: #0060CC;
    --exalt-blue-light: #E8F2FF;
    --exalt-navy: #0A1628;
    --exalt-navy-light: #121F36;
    --surface: #FFFFFF;
    --surface-subtle: #F6F8FB;
    --text-primary: #0A1628;
    --text-secondary: #5A6B80;
    --text-muted: #8E9BB0;
    --border: #E2E8F0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(10, 22, 40, 0.06);
    --shadow-md: 0 4px 24px rgba(10, 22, 40, 0.08);
    --shadow-lg: 0 12px 48px rgba(10, 22, 40, 0.12);
    --shadow-xl: 0 24px 64px rgba(10, 22, 40, 0.18);
    --font-display: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--surface-subtle);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* ============================================
   LOGIN VIEW
   ============================================ */

.login-view {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--exalt-navy);
    z-index: 1000;
    animation: loginFadeIn 0.6s ease-out;
}

@keyframes loginFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Subtle grid background */
.login-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.login-grid {
    position: absolute;
    inset: -50%;
    background-image:
        linear-gradient(rgba(0, 127, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 127, 255, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
    transform: perspective(600px) rotateX(45deg);
    transform-origin: center 30%;
}

.login-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 70% 50% at 50% 40%,
        rgba(0, 127, 255, 0.08) 0%,
        transparent 70%
    );
}

/* Login card */
.login-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 20px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: cardSlideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

@keyframes cardSlideUp {
    from {
        opacity: 0;
        transform: translateY(32px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-card-inner {
    padding: 48px 40px 36px;
    text-align: center;
}

.login-logo {
    height: 44px;
    margin-bottom: 32px;
    filter: brightness(0);
}

.login-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 36px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* Microsoft sign-in button */
.login-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    background: var(--exalt-navy);
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
    justify-content: center;
}

.login-btn:hover {
    background: var(--exalt-blue);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 127, 255, 0.3);
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.login-status {
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    min-height: 1.4em;
}

.login-status.error {
    color: #e74c3c;
}

.login-footer {
    padding: 16px 40px;
    background: var(--surface-subtle);
    border-top: 1px solid var(--border);
    text-align: center;
}

.login-footer span {
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* ============================================
   DASHBOARD VIEW
   ============================================ */

.dashboard-view {
    height: 100vh;
    display: flex;
    flex-direction: column;
    animation: dashFadeIn 0.5s ease-out;
}

@keyframes dashFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Top bar */
.topbar {
    height: 56px;
    min-height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-logo {
    height: 26px;
    filter: brightness(0);
}

.topbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
}

.topbar-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.topbar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.topbar-logout:hover {
    background: #FEE2E2;
    border-color: #FECACA;
    color: #DC2626;
}

/* Report container */
.report-container {
    flex: 1;
    position: relative;
    background: var(--surface-subtle);
}

.report-container iframe {
    border: none !important;
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    top: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface-subtle);
    z-index: 50;
    transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
}

.loader-bar {
    width: 4px;
    height: 32px;
    background: var(--exalt-blue);
    border-radius: 2px;
    animation: loaderPulse 1s ease-in-out infinite;
}

.loader-bar:nth-child(2) { animation-delay: 0.15s; }
.loader-bar:nth-child(3) { animation-delay: 0.3s; }

@keyframes loaderPulse {
    0%, 100% { transform: scaleY(0.4); opacity: 0.4; }
    50% { transform: scaleY(1); opacity: 1; }
}

.loader-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Error container */
.error-container {
    position: absolute;
    inset: 0;
    top: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-subtle);
    z-index: 60;
}

.error-card {
    text-align: center;
    max-width: 400px;
    padding: 48px 40px;
}

.error-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 20px 0 8px;
}

.error-card p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
    word-break: break-word;
}

.error-retry {
    padding: 10px 28px;
    background: var(--exalt-blue);
    color: #FFF;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.error-retry:hover {
    background: var(--exalt-blue-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 127, 255, 0.3);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .login-card-inner {
        padding: 36px 28px 28px;
    }

    .login-title {
        font-size: 1.25rem;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-title {
        display: none;
    }

    .topbar-divider {
        display: none;
    }

    .topbar-user {
        font-size: 0.75rem;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
