/* ============================================
   CSS Variables & Reset
   ============================================ */
:root {
    --primary: #e67e22;
    --primary-dark: #d35400;
    --primary-light: #f39c12;
    --primary-gradient: linear-gradient(135deg, #e67e22 0%, #f39c12 50%, #f5b041 100%);
    --primary-gradient-dark: linear-gradient(135deg, #d35400 0%, #e67e22 50%, #f39c12 100%);
    --accent: #ff6b35;
    --accent-light: #fff3e6;
    --success: #27ae60;
    --success-light: #eafaf1;
    --warning: #f1c40f;
    --danger: #e74c3c;
    --danger-light: #fdedec;
    --bg: #faf6f1;
    --bg-warm: #f8f0e6;
    --card-bg: #ffffff;
    --text: #2c2c2c;
    --text-secondary: #6b6b6b;
    --text-muted: #a0a0a0;
    --border: #ede4da;
    --border-light: #f5efe8;
    --shadow-sm: 0 2px 8px rgba(230, 126, 34, 0.06);
    --shadow: 0 4px 24px rgba(230, 126, 34, 0.08);
    --shadow-hover: 0 12px 40px rgba(230, 126, 34, 0.16);
    --shadow-glow: 0 0 40px rgba(243, 156, 18, 0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Language Bar
   ============================================ */
.lang-bar {
    background: linear-gradient(90deg, #2c2c2c, #3d3d3d);
    padding: 8px 24px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
}

.lang-switch select {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 6px;
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: var(--transition-fast);
}

.lang-switch select:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--primary-light);
}

.lang-switch select option {
    background: #2c2c2c;
    color: #fff;
}

/* ============================================
   Container
   ============================================ */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

/* ============================================
   Header
   ============================================ */
.header {
    background: var(--primary-gradient);
    margin: 28px -24px 0;
    padding: 48px 48px 44px;
    border-radius: var(--radius) var(--radius) 0 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -60%;
    left: -30%;
    width: 160%;
    height: 220%;
    background: radial-gradient(ellipse, rgba(255, 255, 255, 0.12) 0%, transparent 55%);
    animation: headerGlow 10s ease-in-out infinite;
    pointer-events: none;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

@keyframes headerGlow {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(3%, 2%) scale(1.02);
    }

    66% {
        transform: translate(-2%, -1%) scale(0.98);
    }
}

.header-content {
    position: relative;
    z-index: 1;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 10px;
}

.logo svg {
    color: #fff;
    filter: drop-shadow(0 3px 12px rgba(0, 0, 0, 0.25));
    animation: logoFloat 4s ease-in-out infinite;
}

@keyframes logoFloat {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-5px) rotate(2deg);
    }

    75% {
        transform: translateY(-2px) rotate(-1deg);
    }
}

.logo h1 {
    color: #fff;
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    font-weight: 400;
    margin-bottom: 4px;
}

.author {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.82rem;
    font-weight: 300;
    letter-spacing: 0.5px;
}

/* ============================================
   Main Card
   ============================================ */
.main-card {
    background: var(--card-bg);
    margin: 0 -24px;
    padding: 32px 36px 36px;
    box-shadow: var(--shadow);
    border-radius: 0 0 var(--radius) var(--radius);
    position: relative;
}

.main-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 36px;
    right: 36px;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: 0 0 2px 2px;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.tab-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tab-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.tabs {
    display: flex;
    gap: 0;
    background: var(--bg-warm);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border);
}

.tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 22px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    border-radius: var(--radius-xs);
    position: relative;
}

.tab:hover {
    color: var(--primary);
    background: rgba(230, 126, 34, 0.06);
}

.tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 10px rgba(230, 126, 34, 0.35);
}

.tab.active svg {
    stroke: #fff;
}

.stats-box {
    background: var(--accent-light);
    border: 1px solid #fde2c8;
    border-radius: var(--radius-sm);
    padding: 14px 28px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    transition: var(--transition);
}

.stats-box:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.stats-box strong {
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
}

/* ============================================
   Form Section
   ============================================ */
.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
}

.accounts-input {
    width: 100%;
    padding: 16px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.8;
    color: var(--text);
    resize: vertical;
    transition: var(--transition);
    background: #fefcfa;
}

.accounts-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(230, 126, 34, 0.1);
    background: #fff;
}

.accounts-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.form-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 8px 12px;
    background: #fdf8f3;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-light);
}

.form-hint svg {
    flex-shrink: 0;
    stroke: var(--primary-light);
}

/* ============================================
   Check Button
   ============================================ */
.check-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 28px;
    margin-top: 24px;
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
}

.check-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    pointer-events: none;
}

.check-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s ease;
}

.check-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(230, 126, 34, 0.4);
}

.check-btn:hover::after {
    left: 150%;
}

.check-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 16px rgba(230, 126, 34, 0.3);
}

.check-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================
   Loading & Progress
   ============================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.spinner {
    width: 26px;
    height: 26px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 18px;
    padding: 0 4px;
}

.progress-bar {
    flex: 1;
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 5px;
    width: 0%;
    transition: width 0.4s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    font-size: 0.88rem;
    color: var(--primary);
    font-weight: 700;
    min-width: 50px;
    text-align: right;
}

/* ============================================
   Results Section
   ============================================ */
.results-section {
    background: var(--card-bg);
    margin: 24px -24px 0;
    padding: 28px 36px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: fadeInUp 0.5s ease;
    border: 1px solid var(--border-light);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.results-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}

.results-header h2 svg {
    stroke: var(--primary);
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #a9dfbf;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.export-btn:hover {
    background: #d5f5e3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.15);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.results-table thead {
    background: linear-gradient(180deg, #fdf5ec, #faf0e4);
}

.results-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 700;
    color: var(--primary-dark);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.results-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.results-table tbody tr {
    transition: var(--transition-fast);
}

.results-table tbody tr:hover {
    background: #fdf8f3;
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-badge.success {
    background: var(--success-light);
    color: var(--success);
}

.status-badge.error {
    background: var(--danger-light);
    color: var(--danger);
}

.view-mail-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius-xs);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.view-mail-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(230, 126, 34, 0.35);
}

/* ============================================
   Email List Section
   ============================================ */
.email-list-section {
    background: var(--card-bg);
    margin: 24px -24px 0;
    padding: 28px 36px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: fadeInUp 0.5s ease;
    border: 1px solid var(--border-light);
}

.email-list-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-warm);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.back-btn:hover {
    background: var(--border);
    color: var(--text);
}

.email-list-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.email-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.email-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    background: #fff;
}

.email-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
}

.email-card.unread {
    background: linear-gradient(90deg, #fff8f0, #fff);
    border-left: 4px solid var(--primary);
}

.email-card.unread .email-card-subject {
    font-weight: 700;
}

.email-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(230, 126, 34, 0.25);
}

.email-card-content {
    flex: 1;
    min-width: 0;
}

.email-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.email-card-from {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.email-card-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
}

.email-card-subject {
    font-size: 0.88rem;
    color: var(--text);
    margin-bottom: 4px;
    font-weight: 500;
}

.email-card-preview {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.72rem;
    color: var(--primary);
    margin-left: 8px;
    font-weight: 600;
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(44, 44, 44, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    width: 100%;
    max-width: 740px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(230, 126, 34, 0.15), 0 8px 30px rgba(0, 0, 0, 0.1);
    animation: modalIn 0.35s ease;
    border: 1px solid var(--border-light);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.93) translateY(16px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 22px 28px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fdf8f3, #fff);
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h3 {
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
    flex: 1;
    margin-right: 16px;
}

.modal-close {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-warm);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.modal-close:hover {
    background: var(--border);
    border-color: var(--primary-light);
}

.modal-close svg {
    stroke: var(--text-secondary);
}

.modal-meta {
    padding: 14px 28px;
    background: #fdf8f3;
    border-bottom: 1px solid var(--border);
}

.meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    font-size: 0.88rem;
}

.meta-row:last-child {
    margin-bottom: 0;
}

.meta-label {
    font-weight: 700;
    color: var(--primary-dark);
    min-width: 42px;
}

.modal-body {
    padding: 28px;
    overflow-y: auto;
    flex: 1;
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--text);
}

.modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-xs);
}

/* ============================================
   Toast
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    font-size: 0.88rem;
    font-weight: 500;
    animation: toastIn 0.35s ease;
    border-left: 4px solid var(--primary);
    max-width: 380px;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   Footer
   ============================================ */
.footer {
    text-align: center;
    padding: 32px 0 16px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.footer a:hover {
    text-decoration: underline;
}

/* ============================================
   Utility
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 0 14px 50px;
    }

    .header {
        margin: 14px -14px 0;
        padding: 32px 24px;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .main-card {
        margin: 0 -14px;
        padding: 22px 18px;
    }

    .main-card::before {
        left: 18px;
        right: 18px;
    }

    .card-top {
        flex-direction: column;
    }

    .stats-box {
        width: 100%;
        justify-content: center;
    }

    .tabs {
        width: 100%;
    }

    .tab {
        flex: 1;
        justify-content: center;
    }

    .results-section,
    .email-list-section {
        margin: 18px -14px 0;
        padding: 20px 18px;
    }

    .results-table th,
    .results-table td {
        padding: 10px 10px;
        font-size: 0.8rem;
    }

    .email-card {
        padding: 14px;
    }

    .modal {
        max-height: 92vh;
    }

    .modal-header {
        padding: 18px 20px;
    }

    .modal-body {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.25rem;
    }

    .logo svg {
        width: 28px;
        height: 28px;
    }

    .tab {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    .check-btn {
        padding: 14px 18px;
        font-size: 0.95rem;
    }
}