/* ============================================================
   Outlook 邮件获取工具 — 深色主题样式
   ============================================================ */

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

/* ---- CSS Variables ---- */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --bg-input: rgba(15, 23, 42, 0.8);
    --border-color: rgba(99, 102, 241, 0.15);
    --border-active: rgba(99, 102, 241, 0.5);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    --accent-blue: #6366f1;
    --accent-purple: #8b5cf6;
    --accent-cyan: #22d3ee;
    --accent-green: #34d399;
    --accent-red: #f87171;
    --accent-amber: #fbbf24;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.06);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99, 102, 241, 0.08), transparent),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(139, 92, 246, 0.06), transparent),
        radial-gradient(ellipse 40% 40% at 50% 50%, rgba(34, 211, 238, 0.04), transparent);
    pointer-events: none;
    z-index: 0;
}

/* ---- Layout ---- */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
}

/* ---- Header ---- */
.app-header {
    text-align: center;
    padding: 32px 0 16px;
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.app-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ---- Glass Card ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-glow);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-color);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.card-title .icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.card-title .icon.blue { background: rgba(99, 102, 241, 0.15); }
.card-title .icon.purple { background: rgba(139, 92, 246, 0.15); }
.card-title .icon.cyan { background: rgba(34, 211, 238, 0.15); }

/* ---- Main Grid ---- */
.main-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 960px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Form Styles ---- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group label .required {
    color: var(--accent-red);
    margin-left: 2px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.82rem;
    line-height: 1.5;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.btn:hover::after {
    opacity: 1;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82rem;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ---- Tabs ---- */
.tab-bar {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    padding: 4px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-blue);
}

.tab-btn:hover:not(.active) {
    color: var(--text-secondary);
}

/* ---- Action Bar ---- */
.action-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input-wrap {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-input-wrap .form-input {
    padding-left: 36px;
}

.search-input-wrap .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---- Emails List ---- */
.emails-container {
    min-height: 300px;
}

.email-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}

.email-empty .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.email-empty p {
    font-size: 0.95rem;
}

.email-item {
    padding: 16px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    cursor: pointer;
    transition: var(--transition);
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
}

.email-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color);
    transform: translateX(4px);
}

.email-item.has-code {
    border-left: 3px solid var(--accent-green);
}

.email-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.email-subject {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.email-from {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.email-preview {
    font-size: 0.82rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.email-codes {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.code-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.25);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-green);
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: var(--transition);
}

.code-badge:hover {
    background: rgba(52, 211, 153, 0.2);
    transform: scale(1.05);
}

.code-badge .copy-hint {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0;
    transition: opacity 0.2s;
}

.code-badge:hover .copy-hint {
    opacity: 1;
}

/* ---- Email Detail Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 720px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s ease;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
    line-height: 1.4;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--glass-bg);
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.modal-close:hover {
    background: rgba(248, 113, 113, 0.15);
    color: var(--accent-red);
}

.modal-meta {
    padding: 12px 24px;
    background: var(--glass-bg);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    font-size: 0.82rem;
}

.modal-meta .label {
    color: var(--text-muted);
    font-weight: 500;
}

.modal-meta .value {
    color: var(--text-secondary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.modal-codes {
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
    background: rgba(52, 211, 153, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-codes .codes-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-green);
}

/* ---- Loading ---- */
.loading-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: var(--radius-lg);
    z-index: 10;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ---- Logs Panel ---- */
.logs-panel {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    max-height: 150px;
    overflow-y: auto;
    display: none;
}

.logs-panel.show {
    display: block;
}

.logs-panel .log-line {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.logs-panel .log-line.ok {
    color: var(--accent-green);
}

.logs-panel .log-line.fail {
    color: var(--accent-red);
}

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    max-width: 360px;
}

.toast.success {
    background: rgba(52, 211, 153, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: var(--accent-green);
}

.toast.error {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--accent-red);
}

.toast.info {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--accent-blue);
}

/* ---- Status Indicator ---- */
.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--glass-bg);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.connected {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

/* ---- Quick Paste ---- */
.quick-paste {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--glass-border);
}

.quick-paste-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---- Animations ---- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

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

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.4);
}

/* ---- Footer ---- */
.app-footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}
