@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&family=Orbitron:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
    --primary-color: #0a192f;
    --secondary-color: #112240;
    --text-primary: #ccd6f6;
    --text-secondary: #8892b0;
    --accent-color: #64ffda;
    --white: #e6f1ff;
    --error: #ff6b6b;
    --scanline-color: rgba(100, 255, 218, 0.03);
    --transition: all 0.25s cubic-bezier(0.645, 0.045, 0.355, 1);
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--primary-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Background Effect (Subtle Grid) */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(rgba(10, 25, 47, 0.9), rgba(10, 25, 47, 0.9)),
        linear-gradient(90deg, rgba(100, 255, 218, 0.03) 1px, transparent 1px),
        linear-gradient(rgba(100, 255, 218, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 40px 40px, 40px 40px;
    z-index: -1;
}

h1,
h2,
h3,
h4 {
    font-family: 'Orbitron', sans-serif;
    color: var(--white);
    margin-top: 0;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--white);
    text-shadow: 0 0 10px rgba(100, 255, 218, 0.5);
}

/* Layout */
.app-container {
    margin: 0 auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
    margin-top: 100px;
    /* Offset for fixed header */
    max-width: 1200px;
}

/* Header */
#main-header {
    background-color: rgba(10, 25, 47, 0.95);
    backdrop-filter: blur(10px);
    height: 80px;
    display: flex;
    align-items: center;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(100, 255, 218, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin: 0 auto;
    max-width: 1200px;
    padding: 0 20px;
}

.logo {
    display: flex;
    align-items: center;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--accent-color);
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(100, 255, 218, 0.3);
}

.logo-text {
    display: block;
    color: var(--accent-color);
    /* Ensure text color matches */
}

.logo span {
    color: var(--accent-color);
    /* Override previous local style */
}

nav ul {
    display: flex;
    gap: 30px;
    list-style: none;
    /* Ensure no bullets */
    padding: 0;
    margin: 0;
}

nav a {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-left: 0;
    /* Reset margin */
}

nav a:hover {
    color: var(--accent-color);
}

/* Forms */
.auth-box {
    background-color: var(--secondary-color);
    border: 1px solid var(--accent-color);
    padding: 40px;
    max-width: 400px;
    margin: 60px auto;
    box-shadow: 0 10px 30px -10px rgba(2, 12, 27, 0.7);
    border-radius: 4px;
}

form label {
    display: block;
    margin-bottom: 8px;
    color: var(--accent-color);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
}

form input {
    background-color: rgba(10, 25, 47, 0.7);
    border: 1px solid rgba(136, 146, 176, 0.3);
    color: var(--white);
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    font-family: 'Inter', sans-serif;
    border-radius: 2px;
    transition: var(--transition);
}

form input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(100, 255, 218, 0.1);
}

button {
    background-color: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 12px 20px;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
    width: 100%;
    transition: var(--transition);
    font-weight: bold;
    letter-spacing: 1px;
}

button:hover {
    background-color: rgba(100, 255, 218, 0.1);
    box-shadow: 0 0 15px rgba(100, 255, 218, 0.2);
}

/* Dashboard / Terminal */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.terminal-window {
    background-color: #050505;
    border: 1px solid var(--accent-color);
    box-shadow: 0 0 20px rgba(100, 255, 218, 0.1);
    font-family: 'VT323', monospace;
    /* Maintain terminal font for content */
    position: relative;
    overflow: hidden;
}

.terminal-header {
    background-color: rgba(100, 255, 218, 0.1);
    color: var(--accent-color);
    padding: 8px 15px;
    border-bottom: 1px solid var(--accent-color);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.terminal-body {
    padding: 20px;
    color: var(--accent-color);
    min-height: 300px;
    font-size: 1.1rem;
    position: relative;
    z-index: 2;
}

/* Email List */
.email-item {
    border-bottom: 1px dashed rgba(100, 255, 218, 0.3);
    padding: 12px 0;
    transition: var(--transition);
}

.email-item:hover {
    background-color: rgba(100, 255, 218, 0.05);
    padding-left: 10px;
    cursor: pointer;
}

.email-header {
    display: grid;
    grid-template-columns: 100px 180px 1fr auto;
    gap: 15px;
    align-items: center;
    font-size: 1rem;
}

.email-date {
    color: var(--text-secondary);
}

.email-sender {
    color: var(--white);
    font-weight: bold;
}

.email-subject {
    color: var(--accent-color);
}

.email-content {
    margin-top: 15px;
    padding: 15px;
    background-color: rgba(100, 255, 218, 0.05);
    border-left: 2px solid var(--accent-color);
    white-space: pre-wrap;
    color: var(--text-primary);
    text-align: left;
    /* display: none;  <-- REMOVED to allow JS animation */
    overflow: hidden;
    /* Ensure hidden content doesn't spill */
}

/* Scanlines for Terminal */
.scanline-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0),
            rgba(255, 255, 255, 0) 50%,
            rgba(0, 0, 0, 0.2) 50%,
            rgba(0, 0, 0, 0.2));
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 10;
    opacity: 0.6;
}

/* Flash Messages */
.flash-messages {
    list-style: none;
    padding: 0;
    margin-bottom: 20px;
}

.flash-message {
    background-color: rgba(100, 255, 218, 0.1);
    border-left: 3px solid var(--accent-color);
    color: var(--white);
    padding: 15px;
    margin-bottom: 10px;
}

/* Admin */
.admin-banner {
    background-color: #330000;
    color: #ff6b6b;
    text-align: center;
    padding: 5px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    border-bottom: 1px solid #ff6b6b;
}

/* Footer */
footer {
    background-color: #020c1b;
    padding: 40px 0 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid rgba(136, 146, 176, 0.1);
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.footer-links a {
    margin: 0 10px;
    color: var(--text-secondary);
}

.footer-links a:hover {
    color: var(--accent-color);
}

/* ============================
   Mobile Responsiveness
   ============================ */

/* Hamburger Menu */
.hamburger {
    display: none;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    width: 30px;
    height: 20px;
    flex-direction: column;
    justify-content: space-between;
    z-index: 1100;
}

.hamburger .bar {
    width: 100%;
    height: 3px;
    background-color: var(--accent-color);
    transition: var(--transition);
}

/* Base Nav Styles (Desktop) */
#nav-menu {
    display: flex;
    gap: 30px;
}

/* Media Queries */
@media (max-width: 768px) {

    /* Header & Nav */
    .header-content {
        justify-content: space-between;
        position: relative;
    }

    .hamburger {
        display: flex;
        /* Show on mobile */
        order: 2;
        /* Ensure it's the last visual item or allows alignment */
    }

    /* Hide the wrapper nav from flow so spacing works, but keep children visible */
    nav {
        position: static;
    }

    #nav-menu {
        position: fixed;
        top: 80px;
        /* Below header */
        left: -100%;
        flex-direction: column;
        background-color: rgba(10, 25, 47, 0.98);
        width: 100%;
        text-align: center;
        transition: 0.3s;
        padding: 20px 0;
        border-bottom: 1px solid var(--accent-color);
        box-shadow: 0 10px 10px rgba(0, 0, 0, 0.5);
    }

    #nav-menu.active {
        left: 0;
    }

    #nav-menu li {
        margin: 15px 0;
    }

    /* Hamburger Animation */
    .hamburger.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .hamburger.active .bar:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active .bar:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }

    /* Dashboard Mobile Layout */
    .email-header {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "meta date"
            "subject trash";
        gap: 10px;
        align-items: flex-start;
    }

    .email-date {
        grid-area: date;
        text-align: right;
        font-size: 0.75rem;
    }

    .email-meta {
        grid-area: meta;
    }

    .email-subject {
        grid-area: subject;
        grid-column: 1 / -1;
        /* Full width subject */
        font-size: 0.95rem;
    }

    .email-header form {
        grid-area: trash;
        justify-self: end;
    }

    /* Adjust font sizes for mobile */
    .logo {
        font-size: 1.4rem;
    }

    /* Hide Nav Divider on Mobile */
    .nav-divider {
        display: none !important;
    }

    /* Prevent IOS Zoom on inputs */
    input[type="text"],
    input[type="password"],
    input[type="email"] {
        font-size: 16px;
    }

    /* Claim Alias Page Mobile */
    .alias-item {
        flex-wrap: nowrap;
        gap: 8px;
    }

    .alias-item .alias-name {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.85rem;
    }

    .alias-status {
        display: none !important;
    }

    .handle-request-form,
    .password-form {
        flex-direction: column;
        align-items: stretch !important;
    }

    .handle-request-form span {
        text-align: right;
        margin-bottom: 10px;
    }

    .password-form button {
        margin-top: 10px;
    }

    /* Admin Table → Card Layout on Mobile */
    .admin-table thead {
        display: none;
    }

    .admin-table tbody tr {
        display: flex;
        flex-direction: column;
        border: 1px solid rgba(255, 107, 107, 0.2);
        padding: 12px;
        margin-bottom: 10px;
        gap: 6px;
    }

    .admin-table tbody td {
        padding: 2px 0 !important;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .admin-table tbody td::before {
        content: attr(data-label);
        color: #ff6b6b;
        font-weight: bold;
        font-size: 0.75rem;
        text-transform: uppercase;
    }
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--text-secondary);
    border-radius: 22px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s ease;
}

input:checked+.toggle-slider {
    background: rgba(100, 255, 218, 0.15);
    border-color: var(--accent-color);
    box-shadow: 0 0 8px rgba(100, 255, 218, 0.3);
}

input:checked+.toggle-slider::before {
    transform: translateX(22px);
    background: var(--accent-color);
    box-shadow: 0 0 6px rgba(100, 255, 218, 0.5);
}