/* ═══════════════════════════════════════════════════════════════
   SLEET MAIL - Apple Glassmorphic Design
   Inspired by macOS Sonoma & iOS 18
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Ultra-minimal Apple-Microsoft palette */
    --primary: #000000;
    --primary-dark: #1a1a1a;
    --primary-light: #333333;
    --secondary: #666666;
    --success: #107C10;
    --danger: #D13438;
    --warning: #CA5010;
    
    /* Clean white backgrounds */
    --glass-white: rgba(255, 255, 255, 0.98);
    --glass-light: rgba(255, 255, 255, 0.95);
    --glass-medium: rgba(250, 250, 250, 1);
    
    /* Text colors */
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #a1a1a6;
    
    /* Minimal blur */
    --blur-sm: 0px;
    --blur-md: 0px;
    --blur-lg: 0px;
    --blur-xl: 0px;
    
    /* Subtle shadows - Microsoft Fluent */
    --shadow-glass: 0 0 0 1px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 0 0 1px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 0 0 1px rgba(0, 0, 0, 0.1);
    
    /* Border radius - Apple style */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
}

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

html {
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    position: relative;
    overscroll-behavior-x: none;
}

html, body {
    max-width: 100vw;
    overscroll-behavior: none;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    background: #f5f5f7;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
    min-height: 100vh;
    overscroll-behavior-x: none;
    -webkit-overflow-scrolling: touch;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.global-error-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: white;
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    display: none;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Page Transitions */
body.page-transitioning {
    pointer-events: none;
}

body.page-fade-out {
    animation: pageFadeOut 0.3s ease-out forwards;
}

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

/* ═══════════════════════════════════════════════════════════════
   ANIMATED BACKGROUND
   ═══════════════════════════════════════════════════════════════ */

.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: #fafafa;
    background-size: 100% 100%;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: #ffffff;
}

.page {
    display: none;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

.page.active {
    display: flex;
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE - Glassmorphic Style
   ═══════════════════════════════════════════════════════════════ */

.login-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    width: 100%;
    height: 100vh;
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

.login-box {
    background: #ffffff;
    padding: 3.5rem 3rem;
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
    border: none;
    width: 100%;
    max-width: 440px;
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.login-box h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    text-align: center;
    letter-spacing: -0.02em;
}

.typing-title {
    display: inline-block;
    overflow: hidden;
    border-right: 2px solid var(--text-primary);
    white-space: nowrap;
    margin: 0 auto;
    animation: typing 2s steps(21) 0.5s 1 normal both,
               blink 0.75s step-end 3s;
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 100% {
        border-color: var(--text-primary);
    }
    50% {
        border-color: transparent;
    }
}

/* Retirer le curseur après l'animation */
.typing-title::after {
    content: '';
    animation: removeCursor 0s 3s forwards;
}

@keyframes removeCursor {
    to {
        border-right-color: transparent;
    }
}

.subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 2.5rem;
    font-size: 1.0625rem;
    font-weight: 400;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.625rem;
    letter-spacing: -0.01em;
}

.input-group input {
    width: 100%;
    padding: 0.875rem 1.125rem;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: #fafafa;
    color: var(--text-primary);
}

.input-group input::placeholder {
    color: var(--text-tertiary);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
}

.btn-primary {
    width: 100%;
    padding: 0.9375rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    letter-spacing: 0;
    box-shadow: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: none;
    box-shadow: none;
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Request Email Button - Glassmorphic */
.btn-request-email {
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.875rem 1.5rem;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-xl);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    letter-spacing: 0;
}

.btn-request-email:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    border-color: rgba(0, 0, 0, 0.12);
}

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

.btn-request-email svg {
    opacity: 0.7;
}

/* Back Link */
.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.back-link:hover {
    color: var(--text-primary);
    gap: 0.75rem;
}

.back-link svg {
    transition: transform 0.2s ease;
}

.back-link:hover svg {
    transform: translateX(-4px);
}

/* Textarea in input group */
.input-group textarea {
    width: 100%;
    padding: 0.875rem 1.125rem;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: #fafafa;
    color: var(--text-primary);
    resize: vertical;
}

.input-group textarea::placeholder {
    color: var(--text-tertiary);
}

.input-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
}

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    padding: 0.875rem 1rem;
    background: rgba(255, 59, 48, 0.1);
    backdrop-filter: blur(var(--blur-sm));
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 59, 48, 0.2);
    display: none;
    animation: shake 0.4s ease;
}

.error-message.show {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   MAIL INTERFACE - Glassmorphic
   ═══════════════════════════════════════════════════════════════ */

.mail-container {
    display: grid;
    grid-template-columns: 280px 400px 1fr;
    height: 100vh;
    gap: 1rem;
    padding: 1rem;
    width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

.sidebar {
    background: #ffffff;
    border-radius: 0;
    border-right: 1px solid #e0e0e0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideInLeft 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar-header {
    padding: 1.75rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sidebar-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.btn-compose {
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    transition: all 0.2s ease;
    box-shadow: none;
}

.btn-compose:hover {
    background: var(--primary-dark);
}

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

.mail-nav {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.mail-nav::-webkit-scrollbar {
    width: 6px;
}

.mail-nav::-webkit-scrollbar-track {
    background: transparent;
}

.mail-nav::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 0.375rem;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.nav-item span:first-of-type {
    flex: 1;
    font-size: 0.9375rem;
}

.badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    padding: 0.1875rem 0.625rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.nav-item:not(.active) .badge {
    background: var(--primary);
    color: white;
}

.sidebar-separator {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 1rem 1.5rem;
}

.btn-services {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    margin: 0 1rem 1rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 0.9375rem;
    background: transparent;
}

.btn-services:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
    transform: translateX(4px);
}

.btn-services svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-top: auto;
}

.user-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.125rem;
    flex-shrink: 0;
    box-shadow: none;
}

.user-details {
    min-width: 0;
    flex: 1;
}

.user-email {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    padding: 0.625rem;
    background: rgba(255, 59, 48, 0.1);
    border: none;
    color: var(--danger);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.05);
}

/* ═══════════════════════════════════════════════════════════════
   MAIL LIST - Glass Panel
   ═══════════════════════════════════════════════════════════════ */

.mail-list {
    background: #ffffff;
    border-radius: 0;
    border-right: 1px solid #e0e0e0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.5s ease-out 0.1s both;
}

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

.mail-list-header {
    padding: 1.75rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mail-list-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.btn-refresh {
    padding: 0.625rem;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-refresh:hover {
    background: var(--primary);
    color: white;
    transform: rotate(180deg);
}

.mail-items {
    flex: 1;
    overflow-y: auto;
}

.mail-items::-webkit-scrollbar {
    width: 6px;
}

.mail-items::-webkit-scrollbar-track {
    background: transparent;
}

.mail-items::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.mail-item {
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
}

.mail-item:hover {
    background: rgba(0, 122, 255, 0.05);
    transform: translateX(4px);
}

.mail-item.active {
    background: rgba(0, 122, 255, 0.1);
    border-left: 3px solid var(--primary);
}

.mail-item.unread {
    background: rgba(0, 122, 255, 0.03);
}

.mail-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.375rem;
}

.mail-from {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
}

.mail-item.unread .mail-from {
    font-weight: 700;
}

.mail-date {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.mail-subject {
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.mail-item.unread .mail-subject {
    font-weight: 600;
}

.mail-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading-state {
    padding: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-tertiary);
}

/* ═══════════════════════════════════════════════════════════════
   MAIL CONTENT - Glass Panel
   ═══════════════════════════════════════════════════════════════ */

.mail-content {
    background: #ffffff;
    border-radius: 0;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    animation: fadeIn 0.5s ease-out 0.2s both;
}

.mail-content::-webkit-scrollbar {
    width: 8px;
}

.mail-content::-webkit-scrollbar-track {
    background: transparent;
}

.mail-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    gap: 1.25rem;
    padding: 3rem;
}

.empty-state svg {
    opacity: 0.4;
}

.empty-state p {
    font-size: 1.0625rem;
    font-weight: 500;
}

.mail-detail {
    padding: 2.5rem;
}

.mail-detail-header {
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 2rem;
}

.mail-detail-subject {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.mail-detail-meta {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.mail-detail-from {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.mail-detail-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.25rem;
    box-shadow: none;
}

.mail-detail-sender {
    flex: 1;
}

.mail-detail-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.0625rem;
    margin-bottom: 0.125rem;
}

.mail-detail-email {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.mail-detail-date {
    font-size: 0.9375rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.mail-detail-body {
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 1rem;
    max-height: calc(100vh - 400px);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.mail-detail-body::-webkit-scrollbar {
    width: 6px;
}

.mail-detail-body::-webkit-scrollbar-track {
    background: transparent;
}

.mail-detail-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

/* Style HTML emails properly - isolated from page styles */
.mail-detail-body {
    /* Create a new stacking context to isolate email styles */
    isolation: isolate;
}

.mail-detail-body img {
    max-width: 100%;
    height: auto;
}

.mail-detail-body table {
    max-width: 100%;
    border-collapse: collapse;
}

.mail-detail-body a {
    color: var(--primary);
    text-decoration: none;
}

.mail-detail-body a:hover {
    text-decoration: underline;
}

/* Prevent email content from affecting global styles */
.mail-detail-body * {
    all: revert;
    font-family: inherit;
    color: inherit;
}

.mail-detail-body a {
    color: var(--primary) !important;
}

/* Scroll indicator */
.scroll-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-top: 1rem;
    background: linear-gradient(to bottom, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.15));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    animation: pulse 2s ease-in-out infinite;
}

.scroll-indicator svg {
    animation: bounce 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(4px);
    }
}

.mail-detail-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.btn-action {
    padding: 0.75rem 1.5rem;
    background: var(--glass-light);
    backdrop-filter: blur(var(--blur-md));
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text-primary);
}

.btn-action:hover {
    background: var(--glass-white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.btn-action.danger:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* ═══════════════════════════════════════════════════════════════
   COMPOSE MODAL - Glassmorphic
   ═══════════════════════════════════════════════════════════════ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(var(--blur-md));
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 8px 24px rgba(0, 0, 0, 0.12);
    border: none;
    width: 100%;
    max-width: 750px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-small {
    max-width: 480px;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    padding: 1.75rem 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.btn-close {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

#compose-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.compose-field {
    padding: 1rem 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.compose-field label {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    width: 80px;
    flex-shrink: 0;
}

.compose-field input,
.compose-field textarea {
    flex: 1;
    border: none;
    font-size: 0.9375rem;
    font-family: inherit;
    background: transparent;
    color: var(--text-primary);
}

.compose-field input:focus,
.compose-field textarea:focus {
    outline: none;
}

.compose-field textarea {
    resize: vertical;
    min-height: 300px;
    line-height: 1.6;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--glass-light);
    backdrop-filter: blur(var(--blur-md));
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-secondary:hover {
    background: var(--glass-white);
    transform: translateY(-1px);
    box-shadow: var(--shadow-card);
}

/* Request Email Form Styles */
.request-field {
    padding: 1.5rem 2rem;
}

.request-field label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.email-input-group {
    display: flex;
    align-items: center;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-sm);
    padding: 0.875rem 1.125rem;
    transition: all 0.2s ease;
}

.email-input-group:focus-within {
    background: #ffffff;
    border-color: var(--primary);
}

.email-input-group input {
    flex: 0 1 auto;
    min-width: 120px;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    outline: none;
    padding: 0;
}

.email-input-group input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.email-domain {
    flex-shrink: 0;
    font-size: 1rem;
    color: var(--text-tertiary);
    font-weight: 400;
    user-select: none;
    pointer-events: none;
}

.field-hint {
    margin-top: 0.625rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE HEADER & HAMBURGER MENU
   ═══════════════════════════════════════════════════════════════ */

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    z-index: 1000;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.mobile-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
    margin: 0;
}

.hamburger-btn {
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    position: relative;
    z-index: 1001;
    -webkit-tap-highlight-color: transparent;
}

.hamburger-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.hamburger-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.hamburger-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.btn-compose-mobile {
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-compose-mobile:active {
    transform: scale(0.95);
    background: var(--primary-dark);
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease, left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

.btn-back-mobile {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.btn-back-mobile:active {
    background: rgba(0, 0, 0, 0.04);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN - COMPREHENSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════ */

/* Large Tablets & Small Desktops (1024px - 1280px) */
@media (max-width: 1280px) {
    .mail-container {
        grid-template-columns: 260px 380px 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .sidebar-header {
        padding: 1.5rem 1.25rem;
    }
    
    .mail-list-header {
        padding: 1.5rem 1.25rem;
    }
    
    .mail-detail {
        padding: 2rem;
    }
}

/* Tablets (768px - 1024px) */
@media (max-width: 1024px) {
    .mail-container {
        grid-template-columns: 280px 1fr;
        gap: 0;
        padding: 0;
    }
    
    .sidebar {
        border-radius: 0;
    }
    
    .mail-list {
        border-radius: 0;
    }
    
    .mail-content {
        display: none;
        border-radius: 0;
    }
    
    .mail-content.show-mobile {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 500;
        background: #ffffff;
    }
    
    .mail-content.show-mobile .btn-back-mobile {
        display: flex;
    }
}

/* Mobile Devices (up to 768px) */
@media (max-width: 768px) {
    body {
        padding-top: 60px;
        position: fixed;
        overflow: hidden;
        touch-action: pan-y;
    }
    
    html {
        overflow-x: hidden;
        overscroll-behavior-x: none;
        width: 100%;
        position: fixed;
    }
    
    .mobile-header {
        display: flex;
    }
    
    #login-page.page.active {
        padding-top: 0;
    }
    
    .login-container {
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 2rem 1rem;
    }
    
    .mail-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 60px);
        padding: 0;
        gap: 0;
        overflow-x: hidden;
        overscroll-behavior-x: none;
        touch-action: pan-y;
    }
    
    /* Sidebar Mobile Behavior */
    .sidebar {
        position: fixed;
        top: 60px;
        left: -100%;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 1001;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 0;
        border-right: 1px solid #e0e0e0;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
        overflow-x: hidden;
        overscroll-behavior-x: none;
        background: #ffffff !important;
        opacity: 1 !important;
    }
    
    .sidebar.show-mobile {
        left: 0;
    }
    
    /* Mail List Mobile */
    .mail-list {
        display: flex;
        border-radius: 0;
        border: none;
        overflow-x: hidden;
        overscroll-behavior-x: none;
        touch-action: pan-y;
    }
    
    .mail-list.hide-mobile {
        display: none;
    }
    
    .mail-list-header {
        padding: 1rem;
    }
    
    .mail-list-header h3 {
        font-size: 1.25rem;
    }
    
    /* Mail Content Mobile */
    .mail-content {
        display: none;
    }
    
    .mail-content.show-mobile {
        display: flex;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 500;
        background: #ffffff;
        border-radius: 0;
        overflow-x: hidden;
        overscroll-behavior-x: none;
        touch-action: pan-y;
    }
    
    .mail-content.show-mobile .btn-back-mobile {
        display: flex;
    }
    
    .mail-detail {
        padding: 1.5rem 1rem;
    }
    
    .mail-detail-header {
        padding-bottom: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .mail-detail-subject {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .mail-detail-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .mail-detail-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .btn-action {
        flex: 1;
        min-width: calc(50% - 0.25rem);
        justify-content: center;
        padding: 0.875rem 1rem;
    }
    
    /* Mail Items Touch Optimization */
    .mail-item {
        padding: 1rem;
        -webkit-tap-highlight-color: transparent;
    }
    
    .mail-item:active {
        background: rgba(0, 122, 255, 0.1);
    }
    
    /* Login Page Mobile */
    .login-box {
        padding: 2rem 1.5rem;
        margin: 0 1rem;
        width: calc(100% - 2rem);
        max-width: 440px;
    }
    
    .login-box h1 {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
    
    /* Modal Mobile */
    .modal {
        padding: 1rem;
        overflow-x: hidden;
        overscroll-behavior-x: none;
    }
    
    .modal-content {
        max-width: 100%;
        max-height: calc(100vh - 2rem);
        border-radius: var(--radius-md);
        overflow-x: hidden;
        overscroll-behavior-x: none;
    }
    
    .modal-header {
        padding: 1.25rem 1.5rem;
    }
    
    .modal-header h3 {
        font-size: 1.25rem;
    }
    
    .compose-field {
        padding: 0.875rem 1.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .compose-field label {
        width: 100%;
        font-size: 0.875rem;
    }
    
    .compose-field textarea {
        min-height: 200px;
    }
    
    .modal-footer {
        padding: 1rem 1.5rem;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
    
    /* Navigation Touch Optimization */
    .nav-item {
        padding: 1rem;
        -webkit-tap-highlight-color: transparent;
    }
    
    .nav-item:active {
        transform: translateX(4px);
    }
    
    /* Buttons Touch Optimization */
    .btn-compose,
    .btn-refresh,
    .btn-logout {
        -webkit-tap-highlight-color: transparent;
    }
    
    .btn-compose:active {
        transform: scale(0.98);
    }
    
    .btn-refresh:active {
        transform: rotate(180deg) scale(0.95);
    }
    
    .btn-logout:active {
        transform: scale(0.95);
    }
    
    /* Pull-to-refresh indicator (mobile only) */
    .pull-to-refresh-indicator {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        height: 60px;
        display: none; /* Hidden on desktop */
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        background: #ffffff;
        border-bottom: 1px solid #e0e0e0;
        z-index: 1001;
        transform: translateY(-100%);
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
        pointer-events: none;
    }
    
    .refresh-spinner {
        width: 20px;
        height: 20px;
        border: 2px solid rgba(0, 0, 0, 0.1);
        border-top-color: var(--primary);
        border-radius: 50%;
        animation: none;
    }
    
    .pull-to-refresh-indicator.ready .refresh-spinner {
        animation: spin 0.8s linear infinite;
    }
    
    .pull-to-refresh-indicator.refreshing .refresh-spinner {
        animation: spin 0.8s linear infinite;
    }
    
    .refresh-text {
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--text-secondary);
    }
    
    .pull-to-refresh-indicator.ready .refresh-text {
        color: var(--primary);
    }
    
    .pull-to-refresh-indicator.refreshing .refresh-text {
        color: var(--primary);
    }
}

/* Small Mobile Devices (up to 480px) */
@media (max-width: 480px) {
    /* Enable pull-to-refresh on mobile */
    .pull-to-refresh-indicator {
        display: flex;
    }
    
    .mobile-header {
        padding: 0 0.75rem;
    }
    
    .mobile-logo {
        font-size: 1.125rem;
    }
    
    .hamburger-btn,
    .btn-compose-mobile {
        width: 40px;
        height: 40px;
    }
    
    .sidebar {
        width: 260px;
    }
    
    .sidebar-header h2 {
        font-size: 1.5rem;
    }
    
    .btn-compose {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .mail-list-header h3 {
        font-size: 1.125rem;
    }
    
    .mail-item {
        padding: 0.875rem;
    }
    
    .mail-from {
        font-size: 0.875rem;
    }
    
    .mail-subject {
        font-size: 0.875rem;
    }
    
    .mail-preview {
        font-size: 0.8125rem;
    }
    
    .mail-detail {
        padding: 1rem;
    }
    
    .mail-detail-subject {
        font-size: 1.25rem;
    }
    
    .mail-detail-avatar {
        width: 44px;
        height: 44px;
        font-size: 1.125rem;
    }
    
    .mail-detail-name {
        font-size: 1rem;
    }
    
    .mail-detail-body {
        font-size: 0.9375rem;
    }
    
    .login-container {
        padding: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .login-box {
        padding: 1.5rem 1rem;
        margin: 0 auto;
        width: calc(100% - 2rem);
        max-width: 440px;
    }
    
    .login-box h1 {
        font-size: 1.5rem;
    }
    
    .typing-title {
        font-size: 1.5rem;
    }
    
    .input-group input,
    .input-group textarea {
        padding: 0.75rem 1rem;
        font-size: 0.9375rem;
    }
    
    .btn-primary {
        padding: 0.875rem 1.25rem;
        font-size: 0.9375rem;
    }
}

/* Extra Small Devices (up to 360px) */
@media (max-width: 360px) {
    .mobile-logo {
        font-size: 1rem;
    }
    
    .sidebar {
        width: 240px;
    }
    
    .sidebar-header {
        padding: 1.25rem 1rem;
    }
    
    .sidebar-header h2 {
        font-size: 1.375rem;
    }
    
    .mail-nav {
        padding: 0.75rem;
    }
    
    .nav-item {
        padding: 0.875rem;
        font-size: 0.875rem;
    }
    
    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .user-email {
        font-size: 0.8125rem;
    }
}

/* Landscape Orientation Optimization */
@media (max-height: 600px) and (orientation: landscape) {
    .mail-detail {
        padding: 1rem;
    }
    
    .mail-detail-header {
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }
    
    .mail-detail-subject {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }
    
    .empty-state svg {
        width: 48px;
        height: 48px;
    }
    
    .loading-state {
        padding: 2rem;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    .mail-item,
    .nav-item,
    .btn-action {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .hamburger-btn span {
        transition: none;
    }
    
    .sidebar,
    .mobile-overlay {
        transition: none;
    }
}

/* ═══════════════════════════════════════════════════════════════
   SERVICES STATUS PAGE
   ═══════════════════════════════════════════════════════════════ */

.services-content {
    background: #ffffff;
    border-radius: 0;
    padding: 2.5rem;
    overflow-y: auto;
    grid-column: 2 / -1;
}

.services-header {
    margin-bottom: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

.services-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.services-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.services-header .btn-refresh {
    position: absolute;
    top: 0;
    right: 0;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.service-card {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.service-card:hover {
    border-color: #d0d0d0;
    transform: translateY(-2px);
}

.service-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.service-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.service-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
}

.service-status.operational {
    background: rgba(16, 124, 16, 0.1);
    color: var(--success);
}

.service-status.degraded {
    background: rgba(255, 149, 0, 0.15);
    color: #ff9500;
}

.service-status.down {
    background: rgba(209, 52, 56, 0.1);
    color: var(--danger);
}

.service-status.checking {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.service-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.service-detail-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.service-detail-label {
    color: var(--text-secondary);
}

.service-detail-value {
    color: var(--text-primary);
    font-weight: 500;
}

.service-detail-value.success {
    color: var(--success);
}

.service-detail-value.error {
    color: var(--danger);
}

.services-footer {
    padding-top: 2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.services-footer p {
    margin-bottom: 0.5rem;
}

.services-note {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

#last-updated {
    font-weight: 500;
    color: var(--text-primary);
}

.btn-services.active {
    background: var(--primary);
    color: white;
}

.btn-back-link {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.btn-back-link:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-refresh.rotating svg {
    animation: spin 1s linear;
}

/* Mobile styles for services page */
@media (max-width: 768px) {
    .services-content {
        padding: 1.5rem 1rem;
    }
    
    .services-header h1 {
        font-size: 1.5rem;
    }
    
    .services-header .btn-refresh {
        position: static;
        align-self: flex-start;
        margin-top: 0.5rem;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .services-content {
        padding: 1rem;
    }
    
    .services-header h1 {
        font-size: 1.25rem;
    }
    
    .service-card {
        padding: 1rem;
    }
}