:root {
    --bg-main: #0a0a0a;
    --sidebar-bg: #111111;
    --card-bg: #161616;
    --primary: #a855f7;
    --accent: #7c3aed;
    --text: #e4e4e7;
    --text-dim: #71717a;
    --border: #27272a;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 40px;
}

.nav-links {
    list-style: none;
}

.nav-links li {
    margin-bottom: 10px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s;
}

.nav-links li.active a, .nav-links a:hover {
    background: rgba(168, 85, 247, 0.1);
    color: var(--primary);
}

.logout-item {
    margin-top: auto;
}

.logout-item a:hover {
    color: #f87171 !important;
    background: rgba(248, 113, 113, 0.1) !important;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.badge {
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.8rem;
}

.badge.idle { background: #27272a; color: #a1a1aa; }
.badge.sending { background: #1e3a8a; color: #60a5fa; animation: pulse 2s infinite; }

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

/* Composer */
.composer-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
}

.form-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
}

.input-group {
    margin-bottom: 20px;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 8px;
}

input, textarea {
    width: 100%;
    background: #09090b;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    color: white;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.primary-btn {
    width: 100%;
    background: linear-gradient(to right, var(--primary), var(--accent));
    color: white;
    border: none;
    padding: 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(168, 85, 247, 0.4);
}

/* Stats Panel */
.stats-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 25px;
    display: flex;
    flex-direction: column;
}

.log-container {
    flex-grow: 1;
    background: #000;
    border-radius: 8px;
    padding: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    margin: 15px 0;
    overflow-y: auto;
    max-height: 400px;
}

.log-entry { margin-bottom: 5px; }
.log-entry.info { color: #60a5fa; }
.log-entry.success { color: #4ade80; }
.log-entry.error { color: #f87171; }

.progress-section {
    margin-top: 10px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 8px;
}

.progress-bar {
    height: 8px;
    background: #27272a;
    border-radius: 4px;
    overflow: hidden;
}

.progress {
    width: 0%;
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

/* Inbox View */
.inbox-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    height: calc(100vh - 150px);
}

.inbox-sidebar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.inbox-actions {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.refresh-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: var(--border);
    color: var(--primary);
}

.message-list {
    flex-grow: 1;
    overflow-y: auto;
}

.no-messages {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.message-item {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    gap: 15px;
    animation: slideIn 0.4s ease forwards;
    opacity: 0;
}

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

.message-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.message-item.active {
    background: rgba(168, 85, 247, 0.12);
    border-left: 4px solid var(--primary);
}

.msg-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: white;
    flex-shrink: 0;
}

.msg-body {
    flex-grow: 1;
    min-width: 0;
}

.message-item.unread::after {
    content: '';
    position: absolute;
    top: 20px;
    right: 20px;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary);
}

.msg-item-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.msg-item-from {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-item-date {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.msg-item-subject {
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 4px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-item-snippet {
    font-size: 0.8rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Message View */
.message-view {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.empty-preview {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    gap: 15px;
}

.empty-preview i {
    font-size: 3rem;
    opacity: 0.2;
}

.message-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.message-header {
    padding: 25px;
    border-bottom: 1px solid var(--border);
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.header-main h2 {
    font-size: 1.4rem;
    font-weight: 600;
}

.delete-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: #f87171;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: rgba(248, 113, 113, 0.1);
}

.header-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
}

#msg-from {
    color: var(--primary);
    font-weight: 500;
}

#msg-date {
    color: var(--text-dim);
    font-size: 0.8rem;
}

.msg-body-frame {
    flex-grow: 1;
    padding: 30px;
    overflow-y: auto;
    background: #fff; /* Email white background */
    color: #333;
    margin: 20px;
    border-radius: 12px;
    font-family: Arial, sans-serif;
    line-height: 1.6;
}

/* Settings View */
.settings-container {
    max-width: 900px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.settings-grid h3 {
    margin-bottom: 20px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
}

.primary-btn.mini {
    margin-top: 10px;
}

/* Multi-Account Styles */
.inbox-account-selector {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inbox-account-selector label {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.inbox-account-selector select {
    background: #09090b;
    border: 1px solid var(--border);
    color: white;
    padding: 10px;
    border-radius: 8px;
    width: 100%;
    font-family: inherit;
    cursor: pointer;
}

.form-card.full-width {
    grid-column: 1 / -1;
}

.setting-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin: -10px 0 20px 0;
}

.accounts-list {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.account-tag {
    background: #09090b;
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 100px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

.account-tag i {
    cursor: pointer;
    color: #f87171;
    transition: transform 0.2s;
}

.account-tag i:hover {
    transform: scale(1.2);
}

#msg-to {
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* --- Mobile Responsiveness --- */
.mobile-only {
    display: none;
}

@media (max-width: 1024px) {
    .composer-container {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }

    body {
        flex-direction: column;
    }

    /* Sidebar Mobile */
    .sidebar {
        position: fixed;
        left: -240px;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        padding: 20px;
        padding-top: 80px; /* Space for fixed header if needed */
    }

    header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: var(--bg-main);
        padding: 15px 20px;
        border-bottom: 1px solid var(--border);
        z-index: 900;
        margin-bottom: 0;
    }

    .header-left {
        display: flex;
        align-items: center;
        gap: 15px;
    }

    #menu-toggle, #back-to-list {
        background: none;
        border: 1px solid var(--border);
        color: white;
        padding: 8px 12px;
        border-radius: 8px;
        cursor: pointer;
    }

    /* Inbox Mobile */
    .inbox-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 120px);
        position: relative;
        overflow: hidden;
    }

    .inbox-sidebar {
        width: 100%;
        height: 100%;
        transition: transform 0.3s ease;
    }

    .message-view {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        background: var(--bg-main);
    }

    .inbox-container.viewing-mail .inbox-sidebar {
        transform: translateX(-100%);
    }

    .inbox-container.viewing-mail .message-view {
        transform: translateX(0);
    }

    .msg-body-frame {
        margin: 10px;
        padding: 15px;
    }

    .input-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .header-main h2 {
        font-size: 1.1rem;
    }
}
