@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
    /* ─── Light Mode (Default) ─── */
    --bg-gradient: linear-gradient(135deg, hsl(210, 20%, 98%) 0%, hsl(210, 30%, 94%) 100%);
    --accent-blue: hsl(210, 100%, 55%);
    --accent-glow: hsla(210, 100%, 60%, 0.15);
    --success: hsl(150, 70%, 40%);
    --warning: hsl(40, 90%, 45%);
    --error: hsl(0, 80%, 55%);

    /* Glassmorphism Surface Tokens */
    --glass-bg: hsla(0, 0%, 100%, 0.7);
    --glass-border: hsla(210, 50%, 10%, 0.1);
    --glass-blur: blur(12px);
    --glass-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.05);

    /* Text Colors */
    --text-main: hsl(215, 25%, 15%);
    --text-sub: hsl(215, 15%, 40%);
    --text-muted: hsl(215, 10%, 60%);

    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Dark Mode Override ─── */
body.dark-mode {
    --bg-gradient: linear-gradient(135deg, hsl(220, 40%, 10%) 0%, hsl(210, 50%, 5%) 100%);
    --accent-blue: hsl(210, 100%, 60%);
    --accent-glow: hsla(210, 100%, 60%, 0.3);
    --success: hsl(150, 80%, 45%);
    --warning: hsl(40, 90%, 55%);
    --error: hsl(0, 85%, 60%);

    --glass-bg: hsla(0, 0%, 100%, 0.05);
    --glass-border: hsla(0, 0%, 100%, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    --text-main: hsla(0, 0%, 100%, 0.95);
    --text-sub: hsla(0, 0%, 100%, 0.6);
    --text-muted: hsla(0, 0%, 100%, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    padding: 10px;
    overflow-x: hidden;
    font-size: 0.85rem;
    transition: background 0.3s ease, color 0.3s ease;
}

h1,
h2,
h3,
.header h1 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ─── Layout ─── */
.container {
    max-width: 100%;
    margin: 0;
}

/* ─── Glassmorphism Utilities ─── */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--glass-shadow);
}

/* ─── Navbar ─── */
.navbar {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 8px;
    position: sticky;
    top: 5px;
    z-index: 100;
}

.navbar a {
    color: var(--text-sub);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 10px;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 6px;
}

.navbar a:hover {
    color: var(--text-main);
    background: hsla(0, 0%, 100%, 0.05);
}

.navbar a.active {
    color: #fff;
    background: var(--accent-blue);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* ─── Header Section ─── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.header h1 {
    font-size: 1.5rem;
    color: var(--text-main);
    background: none;
    -webkit-text-fill-color: initial;
}

body.dark-mode .header h1 {
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-controls input {
    background: hsla(0, 0%, 100%, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-main);
    font-size: 0.8rem;
    outline: none;
    transition: var(--transition-smooth);
    width: 180px;
}

body.dark-mode .header-controls input {
    background: hsla(0, 0%, 0%, 0.2);
    color: #fff;
}

.header-controls input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 8px var(--accent-glow);
}

button {
    background: var(--accent-blue);
    color: #fff !important;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* Theme Toggle Button */
.theme-toggle {
    background: hsla(0, 0%, 0%, 0.05);
    color: var(--text-main) !important;
    border: 1px solid var(--glass-border);
    padding: 0;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: var(--transition-smooth);
}

body.dark-mode .theme-toggle {
    background: hsla(0, 0%, 100%, 0.05);
}

/* ─── Inbox List ─── */
.inbox {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: transparent !important;
    box-shadow: none !important;
}

.mail-item {
    padding: 8px 16px;
    display: grid;
    grid-template-columns: 1fr 250px 180px 200px;
    gap: 16px;
    align-items: center;
    border-radius: 10px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    transition: var(--transition-smooth);
    width: 100%;
    cursor: pointer;
}

.mail-item:hover {
    background: hsla(0, 0%, 100%, 0.1);
    border-color: var(--accent-blue);
    transform: translateX(4px);
}

.mail-subject {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-from {
    color: var(--text-sub);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'JetBrains Mono', monospace;
}

.mail-time {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
}

/* ─── Actions & Elements ─── */
.mail-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.otp-code {
    background: hsla(210, 100%, 50%, 0.08);
    color: var(--accent-blue);
    padding: 4px 12px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: 1px solid hsla(210, 100%, 50%, 0.15);
    font-size: 0.9rem;
    /* Larger OTP */
    line-height: 1;
    display: flex;
    align-items: center;
    height: 32px;
}

body.dark-mode .otp-code {
    background: hsla(210, 100%, 60%, 0.1);
}

.copy-btn {
    background: var(--success);
    color: #fff !important;
    /* Ensure white text on green */
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
}

.open-link-btn {
    background: hsla(210, 100%, 45%, 0.1);
    color: hsl(210, 100%, 30%) !important;
    /* Force dark blue text, even darker now */
    border: 2px solid hsla(210, 100%, 45%, 0.4);
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 700;
}

body.dark-mode .open-link-btn {
    background: hsla(210, 100%, 60%, 0.15);
    color: var(--accent-blue);
    border: 1px solid hsla(210, 100%, 60%, 0.3);
}

/* ─── Modal ─── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(8px);
    background: hsla(0, 0%, 0%, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

body.dark-mode .modal {
    background: hsla(0, 0%, 0%, 0.7);
}

.modal-content {
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    width: 95%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    position: relative;
    animation: modalSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--text-main);
}

body.dark-mode .modal-content {
    background: hsl(220, 40%, 10%);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: hsla(0, 0%, 0%, 0.15);
    /* Much darker background circle */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(0, 0, 0, 0.25) !important;
    /* Force a clear border */
    color: #000 !important;
    /* Force black X */
    cursor: pointer;
    font-size: 28px;
    font-weight: 800;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    background: hsla(0, 0%, 0%, 0.35);
    transform: rotate(90deg);
}

body.dark-mode .modal-close {
    background: hsla(0, 0%, 100%, 0.2);
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: #fff !important;
}

body.dark-mode .modal-close:hover {
    background: hsla(0, 0%, 100%, 0.3);
}

@keyframes modalSlide {
    from {
        transform: translateY(20px) scale(0.98);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h2 {
    font-size: 1.2rem;
    margin-bottom: 5px;
}

.modal-body {
    padding: 20px 25px;
}

.otp-box,
.link-box {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    background: hsla(0, 0%, 0%, 0.03);
}

body.dark-mode .otp-box,
body.dark-mode .link-box {
    background: hsla(0, 0%, 100%, 0.03);
}

.otp-box strong {
    font-size: 1.8rem;
    color: var(--success);
}

.text-preview {
    background: hsla(0, 0%, 0%, 0.05);
    border: 1px solid var(--glass-border);
    padding: 15px;
    border-radius: 10px;
    color: var(--text-sub);
    font-size: 0.85rem;
    line-height: 1.6;
}

body.dark-mode .text-preview {
    background: hsla(0, 0%, 0%, 0.3);
}

/* ─── Responsive & Mobile Optimization ─── */
@media (max-width: 1200px) {
    .mail-item {
        grid-template-columns: 1fr 220px 150px 180px;
    }
}

@media (max-width: 992px) {
    .mail-item {
        grid-template-columns: 1fr 200px 140px;
        gap: 12px;
    }

    .mail-actions {
        grid-column: span 3;
        justify-content: flex-start;
        margin-top: 5px;
    }
}

/* Mobile Specific (Readability Boost) */
@media (max-width: 768px) {
    body {
        font-size: 1rem;
        /* Boosted base font for mobile */
        padding: 5px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 10px 15px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .header-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .header-controls input {
        flex: 1;
        min-width: 200px;
        /* Wider for easier tapping */
        font-size: 1rem;
        padding: 12px;
    }

    button {
        padding: 12px 20px;
        font-size: 1rem;
    }

    .inbox {
        gap: 10px;
    }

    .mail-item {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 15px;
    }

    .mail-subject {
        font-size: 1.1rem;
        white-space: normal;
        /* Allow wrap for long subjects on mobile */
        line-height: 1.4;
    }

    .mail-from {
        font-size: 0.95rem;
    }

    .mail-time {
        font-size: 0.85rem;
    }

    .mail-actions {
        grid-column: span 1;
        justify-content: flex-start;
        flex-wrap: wrap;
        margin-top: 10px;
        gap: 12px;
    }

    .otp-code {
        height: 32px;
        padding: 0 12px;
        font-size: 1rem;
    }

    .copy-btn,
    .open-link-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    /* Modal Mobile optimization */
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .text-preview {
        font-size: 1rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mail-item {
    animation: fadeIn 0.3s ease forwards;
}