@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* Midnight SaaS Dark Theme */
    --bg-main: #0B0F19; /* Deep Space */
    --bg-card: rgba(15, 23, 42, 0.4); /* Translucent Slate */
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-muted: #64748b;
    
    /* Elegant Accents */
    --accent: #6366f1; /* Indigo */
    --accent-hover: #8b5cf6; /* Purple */
    --accent-text: #ffffff;
    
    --success: #10b981;
    --danger: #ef4444;
    
    --radius-lg: 24px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Stunning Abstract Orbs in Background for true SaaS feel */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(140px);
    z-index: -1;
    opacity: 0.12;
    pointer-events: none;
}
body::before {
    top: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: #6366f1;
}
body::after {
    bottom: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: #ec4899;
}

.app-wrapper {
    width: 100%;
    max-width: 1280px; 
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* Header */
.header {
    text-align: center;
}

.logo {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.logo span {
    background: linear-gradient(135deg, #6366f1, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo i {
    color: var(--accent);
    filter: drop-shadow(0 0 15px rgba(99, 102, 241, 0.4));
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 500;
    margin-top: 0.6rem;
    letter-spacing: 0.5px;
}

/* Glassmorphism Main Structure */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.05);
    overflow: hidden; 
}

/* Unified Layout */
.main-content {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    min-height: 550px; 
}

/* Sidebar (Left) */
.email-control-panel {
    padding: 2.5rem 2rem;
    width: 480px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.015);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

/* Inbox (Right) */
.inbox-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: rgba(0, 0, 0, 0.1);
}

/* Switch Tabs */
.tabs {
    display: flex;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.7rem 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}

.tab-btn.active {
    background: var(--border-color);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.tab-content { display: none; }
.tab-content.active {
    display: block;
    animation: fadeAndSlideIn 0.3s ease forwards;
}

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

/* Inputs & Forms */
.email-display-group {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.2rem;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    background: rgba(0,0,0,0.3);
}

.input-icon {
    color: var(--text-tertiary);
    font-size: 1.1rem;
    margin-right: 1rem;
    transition: color 0.3s ease;
}

.input-wrapper:focus-within .input-icon {
    color: var(--accent);
}

.input-wrapper input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    width: 100%;
    min-width: 0;
    outline: none;
    font-weight: 500;
    letter-spacing: 0.3px;
}
.input-wrapper input::placeholder {
    color: var(--text-tertiary);
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
}

.action-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.domain-suffix {
    color: var(--text-tertiary);
    font-size: 0.95rem;
    font-weight: 500;
    flex-shrink: 0;
}

/* Buttons */
.primary-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: var(--accent-text);
    border: none;
    padding: 1.1rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    box-shadow: 0 8px 20px -5px rgba(99, 102, 241, 0.4);
    position: relative;
    overflow: hidden;
}

.primary-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: 0.5s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px -5px rgba(99, 102, 241, 0.5);
}

.primary-btn:hover::before {
    left: 100%;
}

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

.status-bar {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(0,0,0,0.15);
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.02);
    font-weight: 500;
}

/* Inbox Area */
.inbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--border-color);
}

.inbox-header h2 {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.inbox-header h2 i {
    color: var(--accent);
}

.inbox-actions {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.live-status {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.secondary-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.inbox-container {
    position: relative;
    display: flex;
    flex-direction: column;
}

.email-list {
    flex: 1;
    overflow-x: auto;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    color: var(--text-secondary);
    text-align: center;
}

.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-sub {
    font-size: 0.95rem;
    color: var(--text-tertiary);
}

.email-item {
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: transparent;
}

.email-item:hover {
    background: rgba(255,255,255,0.03);
    padding-left: 2.8rem;
}

.email-item:last-child {
    border-bottom: none;
}

.email-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.email-sender {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.05rem;
}

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

.email-subject {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
}

/* Reader */
.email-reader {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.reader-header {
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.15);
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.back-btn:hover {
    color: var(--text-primary);
    transform: translateX(-4px);
}

.reader-header h3 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
}

.reader-meta {
    display: flex;
    gap: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.reader-meta span i {
    color: var(--text-tertiary);
    margin-right: 0.4rem;
}

.reader-body {
    padding: 2.5rem;
    flex: 1;
    overflow-x: auto;
    /* Clean white reading area inside the dark UI for reading external emails properly */
    background: #e2e8f0; 
    color: #0f172a;
    border-radius: 0 0 var(--radius-lg) 0;
    font-size: 1rem;
    line-height: 1.7;
}

.reader-body img, .reader-body video {
    max-width: 100%;
    height: auto;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 0 0 var(--radius-lg) 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-left-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1.2rem;
}

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

.hidden { display: none !important; }

/* Toast */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    color: #0f172a;
    padding: 0.8rem 1.5rem;
    border-radius: 40px;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2000;
}
.toast.show { bottom: 40px; }

/* Bottom Nav - desktop */
.bottom-nav { display: none; }

/* Footer */
footer {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.9rem;
    padding: 1.5rem 0;
}

/* =======================================
   MOBILE APP VIEW
   ======================================= */
@media (max-width: 900px) {
    body {
        padding-bottom: 90px;
    }

    .app-wrapper {
        padding: 1.5rem 1rem;
        gap: 1.5rem;
    }
    
    .logo { font-size: 2.2rem; }
    
    .main-content {
        flex-direction: column;
        min-height: auto;
    }
    
    .email-control-panel {
        width: 100%;
        padding: 2rem 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        background: transparent;
    }
    
    .inbox-header, .email-item, .reader-header, .reader-body {
        padding: 1.5rem;
    }
    
    .reader-body {
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }
    
    .loading-overlay {
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }

    .tabs { display: none; } 

    body[data-view="inbox"] .email-control-panel { display: none !important; }
    
    body[data-view="random"] .inbox-section,
    body[data-view="custom"] .inbox-section,
    body[data-view="restore"] .inbox-section { 
        display: none !important; 
    }

    /* Mobile Bottom Navbar */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; width: 100%;
        background: rgba(15, 23, 42, 0.9);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-color);
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        justify-content: space-evenly;
        height: 85px;
        z-index: 1000;
        box-shadow: 0 -10px 30px rgba(0,0,0,0.3);
    }

    .nav-item {
        background: transparent;
        border: none;
        color: var(--text-tertiary);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
        cursor: pointer;
        font-size: 0.85rem;
        font-weight: 500;
        width: 80px;
        transition: var(--transition);
    }

    .nav-item i {
        font-size: 1.5rem;
        transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    }
    
    body[data-view="random"] .nav-item[data-nav="random"],
    body[data-view="custom"] .nav-item[data-nav="custom"],
    body[data-view="restore"] .nav-item[data-nav="restore"],
    body[data-view="inbox"] .nav-item[data-nav="inbox"] {
        color: var(--accent);
    }
    
    body[data-view="random"] .nav-item[data-nav="random"] i,
    body[data-view="custom"] .nav-item[data-nav="custom"] i,
    body[data-view="restore"] .nav-item[data-nav="restore"] i,
    body[data-view="inbox"] .nav-item[data-nav="inbox"] i {
        transform: translateY(-3px);
    }

    .toast.show { bottom: 95px; }
}
