/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a1a;
    background: #f0f2f5;
}

a {
    color: #0078d4;
    text-decoration: none;
}

/* ── App Layout ───────────────────────────────────────── */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    padding: 4px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: #0078d4;
}

.compose-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 16px 16px;
    padding: 12px 20px;
    background: #0078d4;
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}

.compose-btn:hover {
    background: #106ebe;
    color: #fff;
}

.folder-list {
    flex: 1;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #444;
    transition: background 0.15s;
    font-size: 13px;
}

.folder-item:hover {
    background: #f5f5f5;
    color: #1a1a1a;
}

.folder-item.active {
    background: #e8f0fe;
    color: #0078d4;
    font-weight: 600;
}

.folder-item .material-symbols-outlined {
    font-size: 20px;
}

.folder-name {
    flex: 1;
}

.badge {
    background: #0078d4;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
}

.account-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
    padding: 4px;
    margin-bottom: 4px;
}

.account-info .material-symbols-outlined {
    font-size: 18px;
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #888;
    font-size: 12px;
    padding: 4px;
    transition: color 0.15s;
}

.logout-link:hover {
    color: #c0392b;
}

.logout-link .material-symbols-outlined {
    font-size: 16px;
}

/* ── Main Area ────────────────────────────────────────── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    min-height: 56px;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.msg-count {
    font-size: 12px;
    font-weight: 400;
    color: #888;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #666;
}

.search-form {
    display: flex;
    align-items: center;
    background: #f0f2f5;
    border-radius: 8px;
    padding: 0 12px;
    margin-left: auto;
    min-width: 200px;
    max-width: 400px;
    flex: 1;
}

.search-icon {
    font-size: 20px;
    color: #888;
}

.search-form input {
    border: none;
    background: transparent;
    padding: 8px;
    font-size: 13px;
    width: 100%;
    outline: none;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* ── Flash Messages ───────────────────────────────────── */
.flash-messages {
    padding: 8px 24px;
}

.flash {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 4px;
}

.flash-success {
    background: #d4edda;
    color: #155724;
}

.flash-error {
    background: #f8d7da;
    color: #721c24;
}

/* ── Message List ─────────────────────────────────────── */
.message-list {
    background: #fff;
}

.message-row {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    border-bottom: 1px solid #f0f0f0;
    color: #1a1a1a;
    transition: background 0.1s;
    gap: 12px;
    cursor: pointer;
}

.message-row:hover {
    background: #f8f9fa;
}

.message-row.unread {
    background: #f0f7ff;
}

.message-row.unread .msg-sender,
.message-row.unread .msg-subject {
    font-weight: 700;
}

.msg-sender {
    width: 180px;
    min-width: 180px;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-content {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-subject {
    font-size: 13px;
}

.msg-preview {
    color: #888;
    font-size: 13px;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    min-width: fit-content;
}

.msg-date {
    font-size: 12px;
    color: #888;
}

.msg-attachment-icon {
    font-size: 18px;
    color: #888;
}

.msg-important-icon {
    font-size: 18px;
    color: #c0392b;
}

/* ── Empty State ──────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    color: #999;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    color: #ccc;
}

/* ── Pagination ───────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background: #fff;
}

.page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f0f2f5;
    color: #444;
    transition: background 0.15s;
}

.page-btn:hover {
    background: #e0e0e0;
}

.page-info {
    font-size: 13px;
    color: #666;
}

/* ── Message Detail ───────────────────────────────────── */
.message-detail {
    background: #fff;
    min-height: 100%;
}

.msg-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 24px;
    border-bottom: 1px solid #e0e0e0;
    gap: 4px;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    background: none;
    color: #444;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.toolbar-btn:hover {
    background: #f0f2f5;
}

.toolbar-btn.danger:hover {
    background: #fde8e8;
    color: #c0392b;
}

.toolbar-btn .material-symbols-outlined {
    font-size: 20px;
}

.toolbar-spacer {
    flex: 1;
}

.btn-label {
    display: inline;
}

.back-link {
    display: flex;
    align-items: center;
    color: #666;
    margin-right: 8px;
}

.back-link:hover {
    color: #0078d4;
}

.msg-header {
    padding: 24px;
    border-bottom: 1px solid #f0f0f0;
}

.msg-subject-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.importance-high {
    color: #c0392b;
    font-size: 22px;
}

.msg-from {
    font-size: 14px;
    margin-bottom: 4px;
}

.email-dim {
    color: #888;
    font-size: 12px;
}

.msg-recipients {
    font-size: 13px;
    color: #666;
    margin-bottom: 2px;
}

.msg-recipients .label {
    font-weight: 600;
    color: #888;
}

.msg-date-full {
    font-size: 12px;
    color: #888;
    margin-top: 8px;
}

.msg-body {
    padding: 0;
    min-height: 200px;
}

.email-iframe {
    width: 100%;
    min-height: 300px;
    border: none;
    padding: 24px;
}

.email-text {
    padding: 24px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 14px;
}

/* ── Attachments ──────────────────────────────────────── */
.msg-attachments {
    padding: 16px 24px;
    border-top: 1px solid #f0f0f0;
}

.msg-attachments h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #444;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    color: #444;
    transition: background 0.15s;
    max-width: 300px;
}

.attachment-item:hover {
    background: #e8f0fe;
    border-color: #0078d4;
}

.att-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.att-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.att-size {
    font-size: 11px;
    color: #888;
}

.att-download {
    font-size: 18px;
    color: #888;
    margin-left: auto;
}

/* ── Compose Form ─────────────────────────────────────── */
.compose-form {
    background: #fff;
    min-height: 100%;
    padding: 0;
}

.compose-field {
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid #f0f0f0;
}

.compose-field label {
    width: 70px;
    font-size: 13px;
    font-weight: 500;
    color: #888;
}

.compose-field input {
    flex: 1;
    border: none;
    padding: 12px 0;
    font-size: 14px;
    outline: none;
}

.compose-body {
    padding: 0;
}

.compose-body textarea {
    width: 100%;
    border: none;
    padding: 16px 24px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    min-height: 300px;
}

.compose-attachments {
    padding: 12px 24px;
    border-top: 1px solid #f0f0f0;
}

.file-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f0f2f5;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #444;
    transition: background 0.15s;
}

.file-upload-label:hover {
    background: #e0e0e0;
}

.file-input {
    display: none;
}

.file-list {
    margin-top: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 13px;
    color: #666;
}

.file-size {
    color: #999;
    font-size: 12px;
}

.compose-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #f0f0f0;
}

.send-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: #0078d4;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.send-btn:hover {
    background: #106ebe;
}

.cancel-btn {
    padding: 10px 20px;
    color: #666;
    font-size: 14px;
    border-radius: 6px;
    transition: background 0.15s;
}

.cancel-btn:hover {
    background: #f0f2f5;
}

/* ── Search ───────────────────────────────────────────── */
.search-results {
    background: #fff;
    min-height: 100%;
}

.search-info {
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    color: #666;
}

/* ── Login Page ───────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0078d4 0%, #106ebe 100%);
}

.login-card {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: 48px;
    color: #0078d4;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin-top: 8px;
}

.login-header p {
    color: #888;
    font-size: 14px;
    margin-top: 4px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: #0078d4;
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.1);
}

.login-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: #0078d4;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-btn:hover {
    background: #106ebe;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s;
        box-shadow: none;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    }

    .sidebar-close {
        display: block;
    }

    .hamburger {
        display: block;
    }

    .msg-sender {
        width: 100px;
        min-width: 100px;
    }

    .btn-label {
        display: none;
    }

    .topbar {
        padding: 12px 16px;
    }

    .message-row {
        padding: 12px 16px;
    }

    .msg-header {
        padding: 16px;
    }

    .email-iframe {
        padding: 16px;
    }

    .compose-field {
        padding: 0 16px;
    }

    .compose-body textarea {
        padding: 12px 16px;
    }

    .compose-actions {
        padding: 12px 16px;
    }

    .search-form {
        min-width: 120px;
    }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}
