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

:root {
    --bg-main: #f6f8fc;
    --bg-surface: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;
    --sidebar-bg: #f3f6fc;
    --sidebar-active: #d3e3fd;
    --sidebar-active-text: #041e49;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #0ea5e9;
    --star-color: #f59e0b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --radius: 16px;
    --radius-sm: 8px;
}

[data-theme="dark"] {
    --bg-main: #111827;
    --bg-surface: #1f2937;
    --bg-hover: #374151;
    --bg-active: #4b5563;
    --sidebar-bg: #111827;
    --sidebar-active: #1e3a8a;
    --sidebar-active-text: #60a5fa;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    height: 64px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 10;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    min-width: 220px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.domain-badge {
    font-size: 11px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.search-bar {
    flex: 1;
    max-width: 700px;
    position: relative;
}

.search-bar input {
    width: 100%;
    height: 44px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 0 20px 0 48px;
    font-size: 15px;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s ease;
}

.search-bar input:focus {
    background: var(--bg-surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 20px;
}

.user-profile:hover {
    background: var(--bg-hover);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* App Main Body Layout */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid var(--border-color);
}

.btn-compose {
    width: 100%;
    height: 56px;
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    margin-bottom: 20px;
}

.btn-compose:hover {
    box-shadow: var(--shadow-lg);
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.btn-compose i {
    font-size: 20px;
    color: var(--primary);
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.15s;
}

.nav-item:hover {
    background: var(--bg-hover);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
    font-weight: 600;
}

.nav-item-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.badge-unread {
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 20px 16px 8px 16px;
    letter-spacing: 0.5px;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.storage-widget {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-top: 10px;
}

.storage-bar-bg {
    width: 100%;
    height: 6px;
    background: var(--bg-active);
    border-radius: 3px;
    margin: 8px 0;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    background: var(--primary);
    width: 15%;
    border-radius: 3px;
}

/* Mail Content View Area */
.content-area {
    flex: 1;
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toolbar {
    height: 52px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.email-row {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s;
}

.email-row:hover {
    background: var(--bg-hover);
    box-shadow: inset 3px 0 0 var(--primary);
}

.email-row.unread {
    font-weight: 700;
    background: rgba(37, 99, 235, 0.03);
}

.email-checkbox {
    margin-right: 14px;
    cursor: pointer;
}

.star-btn {
    color: var(--text-muted);
    margin-right: 16px;
    cursor: pointer;
    font-size: 16px;
}

.star-btn.starred {
    color: var(--star-color);
}

.sender-col {
    width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
}

.subject-snippet-col {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 20px;
}

.snippet {
    color: var(--text-muted);
    font-weight: 400;
}

.date-col {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.folder-tag {
    font-size: 11px;
    padding: 2px 8px;
    background: rgba(14, 165, 233, 0.15);
    color: var(--accent);
    border-radius: 4px;
    font-weight: 600;
    margin-right: 8px;
}

/* Email Reader Modal/View */
.email-reader {
    display: none;
    flex: 1;
    flex-direction: column;
    padding: 24px 32px;
    overflow-y: auto;
}

.reader-header {
    margin-bottom: 24px;
}

.reader-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
}

.reader-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.reader-sender-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reader-body {
    line-height: 1.6;
    font-size: 15px;
    color: var(--text-main);
    background: var(--bg-main);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    min-height: 200px;
}

/* Modal Windows */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-card {
    background: var(--bg-surface);
    width: 600px;
    max-width: 90%;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: modalPop 0.2s ease;
}

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

.modal-header {
    background: var(--bg-hover);
    padding: 14px 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-surface);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
