/* ========================================
   TempMail - Premium Dark UI v3.0
   基于 Material Design #121212 深灰主题
   科技感 · 层次感 · 负空间
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Material Design 深色主题色板 */
    --surface-default: #121212;
    --surface-1: #1e1e1e;
    --surface-2: #232323;
    --surface-3: #252525;
    --surface-4: #272727;
    --surface-5: #2c2c2c;

    /* 边框层次 */
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-default: rgba(255, 255, 255, 0.08);
    --border-emphasis: rgba(255, 255, 255, 0.12);

    /* 文字层次 */
    --text-high: rgba(255, 255, 255, 0.87);
    --text-medium: rgba(255, 255, 255, 0.60);
    --text-disabled: rgba(255, 255, 255, 0.38);

    /* 品牌色 - 科技蓝 */
    --primary: #448AFF;
    --primary-variant: #82B1FF;
    --primary-surface: rgba(68, 138, 255, 0.08);
    --primary-hover: rgba(68, 138, 255, 0.12);

    /* 功能色 */
    --success: #00E676;
    --success-surface: rgba(0, 230, 118, 0.08);
    --error: #FF5252;
    --error-surface: rgba(255, 82, 82, 0.08);
    --warning: #FFD740;

    /* 圆角 */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* 阴影 - 用于层次 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* 布局 */
    --header-height: 56px;
    --sidebar-width: 340px;
}

/* ========================================
   Base Styles
   ======================================== */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--surface-default);
    color: var(--text-high);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--primary);
    color: white;
}

/* 等宽字体用于代码/邮箱 */
.mono {
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
}

/* ========================================
   Typography
   ======================================== */
h1,
h2,
h3,
h4 {
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-high);
}

/* ========================================
   Elevation System (层次系统)
   ======================================== */
.elevation-1 {
    background: var(--surface-1);
}

.elevation-2 {
    background: var(--surface-2);
}

.elevation-3 {
    background: var(--surface-3);
}

.elevation-4 {
    background: var(--surface-4);
}

.elevation-5 {
    background: var(--surface-5);
}

/* ========================================
   Interactive States
   ======================================== */
.interactive {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ripple {
    position: relative;
    overflow: hidden;
}

/* ========================================
   Buttons
   ======================================== */
.btn-primary {
    background: var(--primary);
    color: #000;
    border: none;
    padding: 0 24px;
    height: 40px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    background: var(--primary-variant);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--surface-3);
    color: var(--text-high);
    border: 1px solid var(--border-emphasis);
    padding: 0 20px;
    height: 40px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: var(--surface-4);
    border-color: var(--border-emphasis);
}

.btn-danger-solid {
    background: var(--error);
    color: #fff;
    border: none;
    padding: 0 20px;
    height: 40px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-danger-solid:hover {
    background: #ff6b6b;
    box-shadow: 0 0 20px rgba(255, 82, 82, 0.3);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-medium);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.btn-icon:hover {
    background: var(--surface-4);
    color: var(--text-high);
}

.btn-ghost {
    background: transparent;
    color: var(--text-medium);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-ghost:hover {
    background: var(--surface-3);
    color: var(--text-high);
}

/* ========================================
   Forms
   ======================================== */
input {
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    color: var(--text-high);
    padding: 0 16px;
    height: 48px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    width: 100%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

input::placeholder {
    color: var(--text-disabled);
}

input:hover {
    border-color: var(--border-emphasis);
}

input:focus {
    border-color: var(--primary);
    background: var(--surface-2);
    box-shadow: 0 0 0 3px var(--primary-surface);
}

/* ========================================
   Spinner
   ======================================== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-default);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Chip / Badge
   ======================================== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--surface-3);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-medium);
}

.chip.primary {
    background: var(--primary-surface);
    color: var(--primary);
}

/* ========================================
   Layout - Inbox Split View
   ======================================== */
.inbox-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    height: 100vh;
}

/* App Bar / Header */
.header {
    grid-column: 1 / -1;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: relative;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-btn {
    color: var(--text-medium);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--surface-3);
    color: var(--text-high);
}

.back-btn svg {
    width: 18px;
    height: 18px;
}

.inbox-info {
    padding-left: 8px;
    border-left: 1px solid var(--border-default);
}

.inbox-info h1 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.inbox-info p {
    font-size: 12px;
    color: var(--text-disabled);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.3px;
}

.countdown {
    font-size: 12px;
    color: var(--text-disabled);
    font-family: 'JetBrains Mono', monospace;
    padding: 6px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
}

/* Navigation Rail / Sidebar */
.sidebar {
    background: var(--surface-1);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.email-list {
    flex: 1;
    overflow-y: auto;
}

/* Custom Scrollbar */
.email-list::-webkit-scrollbar {
    width: 8px;
}

.email-list::-webkit-scrollbar-track {
    background: transparent;
}

.email-list::-webkit-scrollbar-thumb {
    background: var(--surface-4);
    border-radius: 4px;
}

.email-list::-webkit-scrollbar-thumb:hover {
    background: var(--surface-5);
}

/* Email Item (List Tile) */
.email-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.email-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: background 0.2s;
}

.email-item:hover {
    background: var(--surface-2);
}

.email-item.active {
    background: var(--primary-surface);
}

.email-item.active::before {
    background: var(--primary);
}

.email-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.email-sender {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-high);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.email-time {
    font-size: 11px;
    color: var(--text-disabled);
    font-family: 'JetBrains Mono', monospace;
}

.email-subject {
    font-size: 14px;
    color: var(--text-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.email-snippet {
    font-size: 13px;
    color: var(--text-disabled);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Content Area */
.main-content {
    background: var(--surface-default);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.empty-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-disabled);
    gap: 16px;
}

.empty-view .icon {
    font-size: 48px;
    opacity: 0.3;
}

.empty-view h3 {
    font-size: 16px;
    font-weight: 500;
}

/* Email Detail */
.email-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.detail-header {
    padding: 20px 24px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-subtle);
}

.detail-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.detail-subject {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-high);
    margin-bottom: 20px;
    line-height: 1.3;
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sender-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: #000;
    flex-shrink: 0;
}

.sender-info {
    flex: 1;
}

.sender-info div:first-child {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-high);
}

.sender-info div:last-child {
    font-size: 12px;
    color: var(--text-disabled);
    font-family: 'JetBrains Mono', monospace;
}

/* Verification Code Card */
.code-section {
    margin: 20px 24px;
    background: var(--success-surface);
    border: 1px solid rgba(0, 230, 118, 0.2);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.code-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 10px;
}

.code-label svg {
    width: 20px;
    height: 20px;
}

.code-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-high);
    letter-spacing: 4px;
    background: var(--surface-1);
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
}

/* Email Body Container */
.email-body-container {
    flex: 1;
    padding: 20px 24px;
    background: var(--surface-default);
}

.email-iframe {
    width: 100%;
    height: 100%;
    min-height: 500px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: #fafafa;
}

/* ========================================
   Index Page - Card Grid Layout
   ======================================== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 48px 24px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 48px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo span:first-child {
    font-size: 28px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-high);
    letter-spacing: -0.5px;
}

.stats-group {
    display: flex;
    gap: 32px;
}

.stat-item {
    text-align: right;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-high);
    font-family: 'JetBrains Mono', monospace;
}

.stat-label {
    font-size: 12px;
    color: var(--text-disabled);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Add Mailbox Card */
.add-box {
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 48px;
}

.add-box h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.add-box p {
    font-size: 14px;
    color: var(--text-disabled);
    margin-bottom: 0;
}

.add-inputs {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.input-group {
    flex: 1;
}

/* Mailbox Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* Mailbox Card */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.card:hover {
    background: var(--surface-2);
    border-color: var(--border-emphasis);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card:hover .card-actions {
    opacity: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.card-avatar {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #000;
}

.card-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-high);
    margin-bottom: 4px;
}

.card-email {
    font-size: 13px;
    color: var(--text-disabled);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.3px;
}

.card-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.refresh-badge {
    font-size: 13px;
    color: var(--text-disabled);
    display: flex;
    align-items: center;
    gap: 6px;
}

.refresh-badge.has-mail {
    color: var(--primary);
    font-weight: 600;
}

/* ========================================
   Toast Notification
   ======================================== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface-4);
    border: 1px solid var(--border-emphasis);
    color: var(--text-high);
    padding: 14px 24px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background: var(--error-surface);
    border-color: rgba(255, 82, 82, 0.3);
    color: var(--error);
}

/* ========================================
   Modal Dialog
   ======================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 440px;
    position: relative;
    z-index: 101;
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-disabled);
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--surface-4);
    color: var(--text-high);
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    .inbox-layout {
        grid-template-columns: 1fr;
    }

    .main-content {
        position: fixed;
        inset: 0;
        z-index: 50;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .main-content.active {
        transform: translateX(0);
    }

    .add-inputs {
        flex-direction: column;
    }

    .toolbar {
        flex-direction: column;
        gap: 24px;
        align-items: flex-start;
    }
}