/* ========================================
   TMP Mail — Design System & Styles
   ======================================== */

/* --- CSS Variables / Design Tokens --- */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(18, 18, 26, 0.7);
    --bg-card-hover: rgba(24, 24, 36, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.03);

    --text-primary: #f0f0f5;
    --text-secondary: #8888aa;
    --text-muted: #555570;

    --accent-primary: #6c5ce7;
    --accent-secondary: #a855f7;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --accent-gradient: linear-gradient(135deg, #6c5ce7, #a855f7, #ec4899);

    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 48px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 40px var(--accent-glow);

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* --- Animated Background --- */
.bg-gradient {
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108, 92, 231, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 80% 50%, rgba(168, 85, 247, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 20% 80%, rgba(236, 72, 153, 0.06), transparent);
    z-index: 0;
    pointer-events: none;
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
    pointer-events: none;
    mask-image: radial-gradient(ellipse 80% 60% at center, black, transparent);
}

.floating-orbs {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: rgba(108, 92, 231, 0.2);
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 250px;
    height: 250px;
    background: rgba(168, 85, 247, 0.15);
    top: 60%;
    right: 10%;
    animation-delay: -7s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: rgba(236, 72, 153, 0.12);
    bottom: 10%;
    left: 40%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(40px, 10px) scale(1.02); }
}

/* --- Header --- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    background: rgba(10, 10, 15, 0.7);
    border-bottom: 1px solid var(--border-color);
}

.header-inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-decoration: none;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform var(--transition-base);
}

.logo:hover .logo-icon {
    transform: rotate(-5deg) scale(1.05);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.logo-accent {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--success);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* --- Main --- */
main {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

/* --- Hero Section --- */
.hero-section {
    padding: 60px 0 40px;
    text-align: center;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
}

.hero-line {
    display: block;
}

.gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.7;
}

/* --- Email Card --- */
.email-card {
    position: relative;
    margin-bottom: 40px;
}

.card-glow {
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-lg);
    background: var(--accent-gradient);
    opacity: 0.15;
    filter: blur(1px);
    transition: opacity var(--transition-base);
}

.email-card:hover .card-glow {
    opacity: 0.25;
}

.card-inner {
    position: relative;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    z-index: 1;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.card-icon {
    color: var(--accent-primary);
}

.card-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.email-display {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px 4px 4px 20px;
    transition: border-color var(--transition-base);
}

.email-display:hover,
.email-display:focus-within {
    border-color: var(--accent-primary);
}

.email-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0.02em;
    cursor: text;
    min-width: 0;
}

.email-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* --- Buttons --- */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: var(--font-family);
    font-weight: 500;
}

.btn-copy,
.btn-refresh {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn-copy:hover {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-primary);
    border-color: rgba(108, 92, 231, 0.3);
}

.btn-refresh {
    background: var(--accent-gradient);
    color: white;
    border: none;
}

.btn-refresh:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.btn-refresh:active {
    transform: scale(0.95);
}

.btn-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    pointer-events: none;
    border: 1px solid var(--border-color);
}

.btn:hover .btn-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.copy-feedback {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0 0;
    color: var(--success);
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-4px);
    transition: all var(--transition-base);
}

.copy-feedback.show {
    opacity: 1;
    transform: translateY(0);
}

/* --- Inbox Section --- */
.inbox-section {
    margin-bottom: 40px;
}

.inbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.inbox-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.inbox-title svg {
    color: var(--accent-primary);
}

.inbox-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auto-refresh {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.refresh-indicator {
    display: flex;
    align-items: center;
}

.spinner {
    animation: spin 1.5s linear infinite;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.spinner.active {
    opacity: 1;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.refresh-label {
    font-weight: 500;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
}

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

.toggle-switch label {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255,255,255,0.1);
    border-radius: 999px;
    transition: var(--transition-base);
}

.toggle-switch label::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-base);
}

.toggle-switch input:checked + label {
    background: var(--accent-primary);
}

.toggle-switch input:checked + label::before {
    transform: translateX(16px);
}

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

.btn-sm:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(108, 92, 231, 0.1);
}

.email-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding-left: 32px;
}

.count-number {
    color: var(--accent-primary);
    font-weight: 700;
}

/* --- Inbox List --- */
.inbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.email-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: slideIn 0.3s ease both;
}

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

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

.email-row-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(108, 92, 231, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.email-row-content {
    flex: 1;
    min-width: 0;
}

.email-row-subject {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.email-row-from {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.email-row-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform var(--transition-base);
}

.email-row:hover .email-row-arrow {
    transform: translateX(4px);
    color: var(--accent-primary);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    line-height: 1.6;
}

.waiting-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 20px;
}

.waiting-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary);
    opacity: 0.3;
    animation: dotPulse 1.5s ease-in-out infinite;
}

.waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.3); }
}

/* --- Loading Skeleton --- */
.loading-state {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-row {
    height: 72px;
    background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255,255,255,0.05) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-md);
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

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

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

.modal {
    width: 100%;
    max-width: 720px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-slow);
    box-shadow: var(--shadow-lg);
}

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

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

.modal-title-group {
    flex: 1;
    min-width: 0;
}

.modal-subject {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    word-break: break-word;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.modal-from::before {
    content: 'From: ';
    color: var(--text-muted);
}

.modal-date::before {
    content: 'Date: ';
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-modal-close,
.btn-modal-delete {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-modal-close:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.btn-modal-delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.modal-body {
    flex: 1;
    overflow: auto;
    padding: 0;
}

.email-frame {
    width: 100%;
    min-height: 400px;
    height: 100%;
    border: none;
    background: white;
}

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

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease both;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.toast.toast-success {
    border-color: rgba(16, 185, 129, 0.3);
}

.toast.toast-success .toast-icon {
    color: var(--success);
}

.toast.toast-error {
    border-color: rgba(239, 68, 68, 0.3);
}

.toast.toast-error .toast-icon {
    color: var(--danger);
}

.toast.toast-out {
    animation: toastOut 0.3s ease both;
}

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

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

/* --- Responsive --- */
@media (max-width: 640px) {
    .header-inner {
        padding: 12px 16px;
    }
    
    main {
        padding: 0 16px 60px;
    }
    
    .hero-section {
        padding: 40px 0 24px;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
    
    .card-inner {
        padding: 16px;
    }
    
    .email-display {
        flex-direction: column;
        padding: 12px;
        gap: 12px;
    }
    
    .email-input {
        font-size: 0.9rem;
        text-align: center;
    }
    
    .email-actions {
        width: 100%;
        justify-content: center;
    }
    
    .email-actions .btn {
        flex: 1;
        height: 44px;
    }
    
    .inbox-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .auto-refresh {
        display: none;
    }
    
    .email-count {
        padding-left: 0;
    }
    
    .email-row {
        padding: 12px 16px;
    }
    
    .email-row-icon {
        display: none;
    }
    
    .modal {
        border-radius: var(--radius-lg);
    }
    
    .modal-overlay {
        padding: 12px;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* --- Selection --- */
::selection {
    background: rgba(108, 92, 231, 0.3);
    color: white;
}
