/* ========================================
   Email Page - Complete CSS Replacement for Tailwind
   Version: 2.0 Enhanced & Polished
   Created: 2025-10-02
   Description: Beautiful, modern email interface with complete styling
   ======================================== */

/* ========== CSS Variables ========== */
:root {
    --primary-color: #5d6afb;
    --secondary-color: #8a98ff;
    --accent-color: #ff7e5f;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --dark-color: #2c3e50;
    --gray-light: #eef2f7;
    --gray-medium: #b8c2cc;
    --gray-dark: #6c757d;
    --border-radius: 16px;
    --shadow: 0 6px 15px rgba(0, 0, 0, 0.08);
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s ease;
}

/* ========== Base Reset & Typography ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

*::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
    transition: background 0.2s;
}

*::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    color: var(--dark-color);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 20px;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

input, select, textarea {
    font-family: inherit;
}

h4 {
    font-size: 1.125rem;
    font-weight: 600;
}

/* ========== Accessibility ========== */
:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
.btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 0.375rem;
}

/* ========== Header Styles ========== */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 25px 0;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(30deg);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    position: relative;
    z-index: 1;
}

.header-content h1 {
    font-size: 1.6rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Orbitron', 'Playfair Display', serif;
}

.header-content h1 i {
    font-size: 1.5rem;
}

.header-content h1 span {
    font-size: 1.1rem;
    font-family: 'Zhi Mang Xing', 'Noto Sans SC', sans-serif;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    backdrop-filter: blur(5px);
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(5px);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.current-date {
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 30px;
    backdrop-filter: blur(5px);
}

/* ========== Container ========== */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 40px;
}

/* ========== Top Bar & Search ========== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.search-container {
    position: relative;
    flex: 1;
    min-width: 300px;
}

.search-box {
    width: 100%;
    padding: 15px 20px 15px 50px;
    border: 2px solid transparent;
    border-radius: 50px;
    background: white;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.08),
        0 2px 4px -2px rgba(0, 0, 0, 0.06);
    font-size: 0.938rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-box:hover {
    box-shadow:
        0 6px 12px -2px rgba(0, 0, 0, 0.12),
        0 3px 6px -3px rgba(0, 0, 0, 0.08);
}

.search-box:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow:
        0 8px 20px rgba(59, 130, 246, 0.25),
        0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 1.1rem;
    transition: color 0.2s;
    pointer-events: none;
}

.search-box:focus ~ .search-icon,
.search-box:not(:placeholder-shown) ~ .search-icon {
    color: #3b82f6;
}

/* ========== Statistics Cards ========== */
.stats-container {
    display: flex;
    gap: 15px;
    min-width: 400px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.stat-card {
    min-width: 100px;
    background: white;
    padding: 18px 14px;
    border-radius: 1rem;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.08),
        0 2px 4px -2px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
    flex: 1;
    max-width: 130px;
    height: 110px;
    border: 1px solid transparent;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--card-color-1), var(--card-color-2));
    transition: height 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow:
        0 12px 24px -4px rgba(0, 0, 0, 0.12),
        0 6px 12px -6px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.05);
}

.stat-card:hover::before {
    height: 6px;
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--icon-color);
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--icon-bg);
    transition: all 0.3s;
}

.stat-card:hover .stat-icon {
    transform: scale(1.1);
}

.stat-content {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-number {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 3px;
    color: var(--dark-color);
}

.stat-label {
    color: var(--gray-medium);
    font-size: 0.8rem;
    font-weight: 500;
}

.stat-card:nth-child(1) {
    --card-color-1: #3b82f6;
    --card-color-2: #2563eb;
    --icon-color: #3b82f6;
    --icon-bg: rgba(59, 130, 246, 0.12);
}

.stat-card:nth-child(2) {
    --card-color-1: #22c55e;
    --card-color-2: #16a34a;
    --icon-color: #22c55e;
    --icon-bg: rgba(34, 197, 94, 0.12);
}

.stat-card:nth-child(3) {
    --card-color-1: #f59e0b;
    --card-color-2: #d97706;
    --icon-color: #f59e0b;
    --icon-bg: rgba(245, 158, 11, 0.12);
}

.stat-card:nth-child(4) {
    --card-color-1: #ef4444;
    --card-color-2: #dc2626;
    --icon-color: #ef4444;
    --icon-bg: rgba(239, 68, 68, 0.12);
}

/* ========== Filter Bar ========== */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: white;
    border-radius: 1rem;
    padding: 18px;
    box-shadow:
        0 1px 3px 0 rgba(0, 0, 0, 0.06),
        0 1px 2px -1px rgba(0, 0, 0, 0.04);
}

.filter-btn {
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    padding: 10px 18px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    line-height: 1.4;
    color: #4b5563;
}

.filter-btn:hover:not(.active):not(#accountFilter) {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.15);
}

.filter-btn.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-color: #2563eb;
    box-shadow:
        0 4px 6px -1px rgba(37, 99, 235, 0.3),
        0 2px 4px -2px rgba(37, 99, 235, 0.2);
}

.filter-btn i {
    font-size: 1rem;
    transition: transform 0.2s;
}

.filter-btn.active i {
    transform: scale(1.1);
}

#accountFilter:hover {
    border-color: #bfdbfe;
    transform: translateY(-1px);
}

/* ========== View Container ========== */
.view-container {
    background: white;
    border-radius: 1.25rem;
    padding: 25px;
    box-shadow: var(--shadow);
    min-height: 500px;
    margin-bottom: 20px;
}

/* ========== Gmail-style Email Layout ========== */
.email-main-container {
    padding: 0;
    display: flex;
    overflow: hidden;
    height: calc(100vh - 320px);
    max-height: 700px;
    min-height: 500px;
}

.email-sidebar {
    width: 384px;
    border-right: 1px solid #e5e7eb;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========== Email List Items ========== */
.email-list-item {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border-left: 3px solid transparent;
}

.email-list-item:hover {
    background: linear-gradient(90deg, #f8fafc 0%, #ffffff 100%);
    border-left-color: #93c5fd;
    box-shadow:
        inset 0 0 0 1px rgba(59, 130, 246, 0.05),
        0 1px 2px 0 rgba(0, 0, 0, 0.02);
}

.email-list-item.selected {
    background: linear-gradient(90deg, #dbeafe 0%, #eff6ff 100%);
    border-left-color: #2563eb;
    box-shadow:
        inset 0 0 0 1px rgba(37, 99, 235, 0.1),
        0 1px 3px 0 rgba(37, 99, 235, 0.1);
}

.email-list-item.unread {
    background: linear-gradient(90deg, #fefefe 0%, #ffffff 100%);
    font-weight: 500;
}

.email-list-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: linear-gradient(to bottom, #f59e0b, #d97706);
    border-radius: 0 2px 2px 0;
}

/* ========== Loading State ========== */
.loading-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fafafa 0%, #ffffff 100%);
}

.loading-state .text-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid transparent;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    position: relative;
}

.loading-spinner::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: #3b82f6;
    animation: spin 1.2s linear infinite reverse;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== Empty State ========== */
.empty-placeholder {
    padding: 80px 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: radial-gradient(circle at center, #f9fafb 0%, #ffffff 100%);
}

.empty-placeholder i {
    font-size: 5rem;
    color: #d1d5db;
    opacity: 0.6;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.empty-placeholder span {
    font-size: 1.125rem;
    font-weight: 500;
    color: #6b7280;
}

/* ========== Email Detail Panel ========== */
.email-detail-panel {
    flex: 1;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.email-detail-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #f9fafb 0%, #ffffff 100%);
}

.email-detail-empty i {
    opacity: 0.4;
    animation: float 3s ease-in-out infinite;
}

.email-detail-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

/* ========== Email Header ========== */
.email-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: white;
}

.email-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.email-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.email-header-sender {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

/* ========== Email Body ========== */
.email-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.email-body-content {
    line-height: 1.7;
    word-wrap: break-word;
    max-width: 100%;
    color: #1f2937;
    font-size: 0.9375rem;
}

.email-body-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.email-body-content pre {
    white-space: pre-wrap;
    background-color: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    border-left: 4px solid var(--primary-color);
    margin: 15px 0;
    font-size: 0.9rem;
}

.email-body-content code {
    background-color: #f1f5f9;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #e11d48;
}

.email-body-content a {
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.email-body-content a:hover {
    color: var(--secondary-color);
}

.email-body-content p {
    margin: 12px 0;
    line-height: 1.8;
}

.email-body-content h1,
.email-body-content h2,
.email-body-content h3 {
    margin: 16px 0 10px;
    font-weight: 600;
    color: #111827;
}

.email-body-content h1 { font-size: 1.5rem; }
.email-body-content h2 { font-size: 1.25rem; }
.email-body-content h3 { font-size: 1.125rem; }

.email-body-content ul,
.email-body-content ol {
    margin: 12px 0;
    padding-left: 30px;
}

.email-body-content li {
    margin: 8px 0;
    line-height: 1.7;
}

.email-body-content blockquote {
    border-left: 4px solid #e5e7eb;
    padding-left: 20px;
    margin: 20px 0;
    color: #6b7280;
    font-style: italic;
    background: #f9fafb;
    padding: 15px 20px;
    border-radius: 4px;
}

.email-body-content div {
    margin: 8px 0;
}

/* ========== Compose Email Button ========== */
.compose-email-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #ff7e5f 0%, #ff6b95 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.75rem;
    cursor: pointer;
    box-shadow:
        0 12px 28px rgba(255, 126, 95, 0.4),
        0 0 0 0 rgba(255, 126, 95, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow:
            0 12px 28px rgba(255, 126, 95, 0.4),
            0 0 0 0 rgba(255, 126, 95, 0.4);
    }
    50% {
        box-shadow:
            0 12px 28px rgba(255, 126, 95, 0.4),
            0 0 0 10px rgba(255, 126, 95, 0);
    }
}

.compose-email-btn:hover {
    transform: scale(1.12);
    box-shadow:
        0 16px 36px rgba(255, 126, 95, 0.5),
        0 0 0 0 rgba(255, 126, 95, 0);
    animation: none;
}

.compose-email-btn:active {
    transform: scale(1.05);
}

/* ========== Modal Overlay ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
    cursor: pointer;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-overlay.hide {
    display: none !important;
}

/* ========== Modal Content ========== */
.modal-content {
    background: white;
    border-radius: 1.25rem;
    box-shadow:
        0 20px 40px -10px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 42rem;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: center;
    cursor: auto;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content-wide {
    max-width: 56rem;
}

.modal-content-medium {
    max-width: 42rem;
}

/* ========== Modal Header ========== */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(to bottom, #ffffff, #f9fafb);
    border-radius: 1.25rem 1.25rem 0 0;
}

.modal-header h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.modal-header .btn-icon {
    flex-shrink: 0;
}

/* ========== Modal Body ========== */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.75rem 1.25rem;
}

/* ========== Modal Footer ========== */
.modal-footer {
    padding: 1.25rem 1.75rem;
    border-top: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to bottom, #ffffff, #fafafa);
    border-radius: 0 0 1.25rem 1.25rem;
}

.modal-footer .btn {
    min-width: 120px;
    padding: 0.625rem 1.5rem;
}

/* ========== Form Styles ========== */
.form-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.875rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.form-row:hover {
    border-bottom-color: #cbd5e1;
}

.form-row:focus-within {
    border-bottom-color: #3b82f6;
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.03) 0%, transparent 100%);
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    border-radius: 0.5rem 0.5rem 0 0;
}

.form-label {
    color: #6b7280;
    width: 5rem;
    flex-shrink: 0;
    font-weight: 500;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.form-row:focus-within .form-label {
    color: #3b82f6;
    font-weight: 600;
}

.form-input,
.form-select {
    flex: 1;
    padding: 0.5rem 0.5rem;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    line-height: 1.5;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    color: #1f2937;
}

.form-input:hover,
.form-select:hover {
    color: #111827;
}

.form-input:focus,
.form-select:focus {
    color: #111827;
}

.form-input::placeholder {
    color: #9ca3af;
    opacity: 1;
    font-weight: 400;
}

.form-textarea {
    width: 100%;
    padding: 1rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.6;
    min-height: 200px;
    resize: vertical;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fafafa;
    outline: none;
    color: #1f2937;
}

.form-textarea:hover {
    border-color: #cbd5e1;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.form-textarea:focus {
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow:
        0 0 0 3px rgba(59, 130, 246, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-textarea::placeholder {
    color: #9ca3af;
    opacity: 1;
    font-weight: 400;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
}

@media (min-width: 768px) {
    .form-grid-md-two-cols {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.form-field {
    display: flex;
    flex-direction: column;
}

.form-field-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

.form-field-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: #ffffff;
}

.form-field-input:hover {
    border-color: #cbd5e1;
}

.form-field-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow:
        0 0 0 3px rgba(59, 130, 246, 0.12),
        0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.form-field-input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

/* ========== Button Styles ========== */
.btn {
    padding: 0.625rem 1.5rem;
    border-radius: 0.625rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow:
        0 1px 3px 0 rgba(0, 0, 0, 0.1),
        0 1px 2px -1px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -2px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-secondary {
    color: #4b5563;
    background: #f9fafb;
    padding: 0.625rem 1.25rem;
    border: 1px solid #e5e7eb;
    font-weight: 500;
}

.btn-secondary:hover {
    background: #f3f4f6;
    color: #1f2937;
    border-color: #d1d5db;
}

/* ========== Reply Button ========== */
.reply-btn {
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 0.625rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 2px 6px rgba(59, 130, 246, 0.3),
        0 1px 2px rgba(0, 0, 0, 0.05);
}

.reply-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow:
        0 4px 10px rgba(59, 130, 246, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.reply-btn i {
    font-size: 0.875rem;
}

.btn-icon {
    padding: 0.625rem;
    background: transparent;
    border-radius: 0.75rem;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    border: none;
    cursor: pointer;
    font-size: 1.125rem;
}

.btn-icon:hover {
    background: #f3f4f6;
    color: #1f2937;
    transform: scale(1.05);
}

.btn-icon:active {
    background: #e5e7eb;
    transform: scale(0.98);
}

.btn-large {
    padding: 0.75rem 2rem;
    font-size: 1.125rem;
}

/* ========== Toast Notification ========== */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    pointer-events: none;
}

.toast-container.hide {
    display: none !important;
}

.toast {
    background: rgba(255, 255, 255, 0.95);
    box-shadow:
        0 20px 25px -5px rgba(0, 0, 0, 0.15),
        0 8px 10px -6px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    border-left: 4px solid;
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    min-width: 280px;
    backdrop-filter: blur(10px);
}

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

.toast.border-green-500 {
    border-left-color: #22c55e;
    background: rgba(240, 253, 244, 0.95);
}

.toast.border-red-500 {
    border-left-color: #ef4444;
    background: rgba(254, 242, 242, 0.95);
}

.toast.border-blue-500 {
    border-left-color: #3b82f6;
    background: rgba(239, 246, 255, 0.95);
}

.toast i.fa-check-circle,
.toast i.fa-exclamation-circle,
.toast i.fa-info-circle {
    font-size: 1.25rem;
}

/* ========== Provider Badge ========== */
.provider-badge {
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 12px;
    color: white;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.provider-badge.qq {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.provider-badge.gmail {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.provider-badge.outlook {
    background: linear-gradient(135deg, #0078d4 0%, #005a9e 100%);
}

.provider-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ========== Avatar Styles ========== */
.avatar {
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}

.avatar-sm {
    width: 2.5rem;
    height: 2.5rem;
}

.avatar-md {
    width: 3rem;
    height: 3rem;
}

.avatar-lg {
    width: 5rem;
    height: 5rem;
}

.avatar-gradient-blue {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.avatar-blue {
    background: #3b82f6;
}

.avatar-shadow {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* ========== Email Detail Modal (Full Screen) ========== */
.email-detail-modal {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 50;
}

.email-detail-modal.hidden {
    display: none;
}

.email-detail-modal.flex {
    display: flex !important;
}

.email-detail-modal-layout {
    height: 100%;
    display: flex;
}

/* ========== Sidebar Email List (in modal) ========== */
.sidebar-email-list-container {
    width: 20rem;
    border-right: 1px solid #e5e7eb;
    background: white;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

/* ========== Account Management ========== */
.account-list-item {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border-color 0.2s;
}

.account-list-item:hover {
    border-color: #93c5fd;
}

.account-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.account-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.account-avatar i {
    font-size: 1.5rem;
}

.account-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ========== Toggle Switch ========== */
.toggle-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch {
    width: 2.75rem;
    height: 1.5rem;
    background: #e5e7eb;
    border-radius: 9999px;
    position: relative;
    transition: background-color 0.2s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 9999px;
    height: 1.25rem;
    width: 1.25rem;
    transition: transform 0.2s;
}

.toggle-input:checked + .toggle-switch {
    background: #2563eb;
}

.toggle-input:checked + .toggle-switch::after {
    transform: translateX(1.25rem);
    border-color: white;
}

.toggle-input:focus + .toggle-switch {
    outline: none;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3);
}

.toggle-label {
    margin-left: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

/* ========== Welcome Modal ========== */
.welcome-icon {
    width: 5rem;
    height: 5rem;
    background: #dbeafe;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

/* ========== Info Box ========== */
.info-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: #eff6ff;
    border-left: 3px solid #3b82f6;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #1e40af;
}

.info-box i {
    flex-shrink: 0;
    font-size: 1rem;
    color: #3b82f6;
}

/* ========== Text Utilities ========== */
.text-center { text-align: center; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-800 { color: #1f2937; }
.text-gray-900 { color: #111827; }
.text-blue-500 { color: #3b82f6; }
.text-blue-600 { color: #2563eb; }
.text-blue-700 { color: #1d4ed8; }
.text-green-500 { color: #22c55e; }
.text-red-500 { color: #ef4444; }
.text-red-600 { color: #dc2626; }
.text-red-700 { color: #b91c1c; }
.text-white { color: white; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
.text-6xl { font-size: 3.75rem; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ========== Spacing Utilities ========== */
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 0.75rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }

.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }

.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

.py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.pb-3 { padding-bottom: 0.75rem; }
.pt-4 { padding-top: 1rem; }
.pt-6 { padding-top: 1.5rem; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }

/* ========== Layout Utilities ========== */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.block { display: block; }
.hidden { display: none; }
.hide { display: none !important; }

.flex-1 { flex: 1 1 0%; }
.flex-col { flex-direction: column; }
.flex-shrink-0 { flex-shrink: 0; }

.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

.w-2 { width: 0.5rem; }
.w-10 { width: 2.5rem; }
.w-12 { width: 3rem; }
.w-20 { width: 5rem; }
.w-80 { width: 20rem; }
.w-96 { width: 24rem; }
.w-full { width: 100%; }

.h-2 { height: 0.5rem; }
.h-6 { height: 1.5rem; }
.h-10 { height: 2.5rem; }
.h-12 { height: 3rem; }
.h-20 { height: 5rem; }
.h-full { height: 100%; }

.min-w-0 { min-width: 0; }
.max-w-none { max-width: none; }
.max-w-4xl { max-width: 56rem; }

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }

/* ========== Border Utilities ========== */
.border { border-width: 1px; }
.border-b { border-bottom-width: 1px; }
.border-r { border-right-width: 1px; }
.border-t { border-top-width: 1px; }
.border-l-4 { border-left-width: 4px; }

.border-gray-100 { border-color: #f3f4f6; }
.border-gray-200 { border-color: #e5e7eb; }
.border-gray-300 { border-color: #d1d5db; }
.border-l-blue-500 { border-left-color: #3b82f6; }

.rounded { border-radius: 0.25rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-full { border-radius: 9999px; }

/* ========== Background Utilities ========== */
.bg-white { background-color: white; }
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-200 { background-color: #e5e7eb; }
.bg-gray-500 { background-color: #6b7280; }
.bg-blue-50 { background-color: #eff6ff; }
.bg-blue-100 { background-color: #dbeafe; }
.bg-blue-500 { background-color: #3b82f6; }
.bg-blue-600 { background-color: #2563eb; }
.bg-blue-700 { background-color: #1d4ed8; }
.bg-red-100 { background-color: #fee2e2; }
.bg-red-700 { background-color: #b91c1c; }
.bg-orange-500 { background-color: #f59e0b; }

/* ========== Shadow Utilities ========== */
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }

/* ========== Overflow Utilities ========== */
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }

/* ========== Position Utilities ========== */
.fixed { position: fixed; }
.absolute { position: absolute; }
.relative { position: relative; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-6 { top: 1.5rem; }
.right-6 { right: 1.5rem; }

/* ========== Misc Utilities ========== */
.cursor-pointer { cursor: pointer; }
.opacity-0 { opacity: 0; }
.outline-none { outline: 2px solid transparent; outline-offset: 2px; }
.resize-none { resize: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.z-50 { z-index: 50; }

.transition-colors {
    transition-property: color, background-color, border-color;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* ========== Prose (Typography) ========== */
.prose {
    color: #374151;
    max-width: 65ch;
}

.prose-slate {
    color: #334155;
}

/* ========== Hover Effects ========== */
.hover\:bg-gray-50:hover { background-color: #f9fafb; }
.hover\:bg-gray-100:hover { background-color: #f3f4f6; }
.hover\:bg-blue-700:hover { background-color: #1d4ed8; }
.hover\:bg-red-50:hover { background-color: #fef2f2; }
.hover\:text-gray-800:hover { color: #1f2937; }
.hover\:border-blue-300:hover { border-color: #93c5fd; }
.hover-bg-gray-50:hover { background-color: #f9fafb; }
.hover-bg-red-50:hover { background-color: #fef2f2; }

/* ========== Custom Select Dropdown ========== */
.select-custom {
    appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27currentColor%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3e%3cpolyline points=%276 9 12 15 18 9%27%3e%3c/polyline%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 35px;
    cursor: pointer;
}

/* ========== Input Autocomplete ========== */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px white inset;
    box-shadow: 0 0 0 30px white inset;
}

/* ========== Email List Scrollbar ========== */
#emailList::-webkit-scrollbar {
    width: 6px;
}

#emailList::-webkit-scrollbar-track {
    background: #f9fafb;
}

#emailList::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 3px;
}

#emailList::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* ========== Bottom Navigation (iOS Style) ========== */
.bottom-nav {
    position: fixed;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(245, 245, 247, 1);
    backdrop-filter: blur(30px) saturate(2);
    border-radius: 11px;
    padding: 8px 16px;
    z-index: 99;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.1),
        0 0 0 0.5px rgba(255, 255, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 0.5px solid rgba(0, 0, 0, 0.04);
    -webkit-backdrop-filter: blur(30px) saturate(2);
}

.nav-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #8e8e93;
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    padding: 6px 10px;
    border-radius: 10px;
    position: relative;
    min-width: 45px;
    cursor: pointer;
}

.nav-item.active {
    color: #007aff;
    background: rgba(0, 122, 255, 0.08);
    transform: scale(1.03);
}

.nav-item.active .nav-icon {
    transform: scale(1.05);
}

.nav-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1px;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.nav-label {
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0.8;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.nav-item.active .nav-label {
    opacity: 1;
    font-weight: 600;
}

.nav-item:hover:not(.active) {
    color: #007aff;
    background: rgba(0, 122, 255, 0.04);
    transform: scale(1.01);
}

.nav-item:active {
    transform: scale(0.97);
}

/* ========== Responsive Design ========== */
@media (max-width: 1024px) {
    .stats-container {
        min-width: auto;
        width: 100%;
        justify-content: space-between;
    }

    .stat-card {
        max-width: calc(25% - 12px);
        min-width: 90px;
    }

    .email-main-container {
        height: calc(100vh - 360px);
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .header-content h1 {
        font-size: 1.3rem;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
    }

    .top-bar {
        flex-direction: column;
    }

    .search-container {
        min-width: 100%;
        order: -1;
    }

    .stats-container {
        width: 100%;
        gap: 10px;
    }

    .stat-card {
        max-width: calc(50% - 5px);
        min-width: auto;
    }

    .email-main-container {
        flex-direction: column;
        height: auto;
        min-height: 600px;
    }

    .email-sidebar {
        width: 100%;
        max-height: 400px;
        border-right: none;
        border-bottom: 2px solid #e5e7eb;
    }

    .email-detail-panel {
        min-height: 400px;
    }

    .compose-email-btn {
        bottom: 80px;
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    .modal-content {
        max-width: 95%;
        margin: 1rem;
    }

    .form-grid-md-two-cols {
        grid-template-columns: 1fr;
    }

    .md\:grid-cols-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .filter-bar {
        gap: 8px;
        padding: 12px;
    }

    .filter-btn {
        font-size: 0.813rem;
        padding: 8px 14px;
    }

    .stat-card {
        padding: 12px 10px;
        height: 90px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }

    .stat-number {
        font-size: 1.1rem;
    }
}

/* ========== Dark Mode Support ========== */
@media (prefers-color-scheme: dark) {
    .bottom-nav {
        background: rgba(30, 30, 30, 0.85);
        border: 0.5px solid rgba(255, 255, 255, 0.08);
        box-shadow:
            0 4px 30px rgba(0, 0, 0, 0.25),
            0 0 0 0.5px rgba(255, 255, 255, 0.05),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }

    .nav-item {
        color: #a1a1a6;
    }

    .nav-item.active {
        color: #0984ff;
        background: rgba(9, 132, 255, 0.12);
    }

    .nav-item:hover:not(.active) {
        color: #0984ff;
        background: rgba(9, 132, 255, 0.06);
    }
}
