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

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2333;
    --bg-card: #161b2e;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent: #3fb950;
    --accent-hover: #2ea043;
    --danger: #f85149;
    --danger-hover: #da3633;
    --border: rgba(240, 246, 252, 0.08);
    --border-light: rgba(240, 246, 252, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

a { color: var(--accent); text-decoration: none; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-icon {
    width: 28px;
    height: 28px;
    color: var(--accent);
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge {
    background: var(--accent);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.email-count {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
}
.btn-outline:hover { background: rgba(255,255,255,0.05); }

.btn-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}
.btn-danger:hover { background: rgba(248,81,73,0.1); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.btn-icon-danger:hover { background: rgba(248,81,73,0.15); color: var(--danger); }

/* ── Main Content ────────────────────────────────────────────────────────── */
.main-content {
    padding: 24px 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ── Table Card (Main Inbox) ─────────────────────────────────────────────── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 500px;
}

.email-table {
    width: 100%;
    border-collapse: collapse;
}

.email-table thead {
    background: var(--bg-tertiary);
}

.email-table th {
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.email-table td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.col-sender { width: 18%; }
.col-receiver { width: 18%; }
.col-subject { width: 32%; }
.col-folder { width: 8%; }
.col-time { width: 14%; }
.col-view { width: 10%; text-align: center; }
.col-check { width: 40px; text-align: center; }
.col-actions { white-space: nowrap; }

.folder-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent);
}
.folder-badge.junk {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger);
}

/* ── Accounts Table ──────────────────────────────────────────────────────── */
.accounts-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.accounts-table-wrap {
    overflow-x: auto;
}

.accounts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.accounts-table thead {
    background: var(--bg-tertiary);
}

.accounts-table th {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.accounts-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.accounts-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.cell-truncate {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.masked {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.masked.revealed {
    color: var(--text-primary);
}

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

/* ── Settings Rows ───────────────────────────────────────────────────────── */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
}

.setting-label {
    font-size: 14px;
    font-weight: 500;
    margin-right: 12px;
}

.setting-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.setting-sublabel {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 8px;
}

.status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 4px;
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent);
    letter-spacing: 0.5px;
}
.status-badge.locked {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger);
}
.status-badge.on {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent);
}

/* ── Toggle Switch ───────────────────────────────────────────────────────── */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    transition: 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.2s;
}
.toggle input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: #000;
}

/* ── Lock Background ─────────────────────────────────────────────────────── */
.lock-bg-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.lock-bg-preview {
    width: 100%;
    max-width: 480px;
    aspect-ratio: 16/9;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 12px;
}

.lock-bg-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-bg {
    font-size: 13px;
    color: var(--text-muted);
}

.lock-bg-actions {
    display: flex;
    gap: 8px;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

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

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b949e' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.form-group select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-row {
    display: flex;
    gap: 12px;
}
.flex-1 { flex: 1; }

.form-group textarea {
    resize: vertical;
    font-family: monospace;
    font-size: 12px;
}

.form-group code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.import-result {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 12px;
    font-family: monospace;
    white-space: pre-wrap;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-muted);
    gap: 12px;
}
.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}
.empty-state p {
    font-size: 13px;
}
.empty-state.small {
    padding: 30px 20px;
}

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-lg {
    max-width: 960px;
    max-height: 90vh;
}

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

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}
.modal-close:hover { background: rgba(255,255,255,0.05); }

.modal-meta {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.modal-meta strong { color: var(--text-primary); }

.modal-body {
    padding: 20px;
}

.email-body-content {
    min-height: 200px;
}

/* ── Login Page ──────────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-top: 12px;
}

.login-brand p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.login-error {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

/* ── Locked Page ─────────────────────────────────────────────────────────── */
.locked-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    overflow: hidden;
}

.locked-video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    transform: translate(-50%, -50%);
    object-fit: cover;
    z-index: 0;
}

.locked-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.locked-card {
    position: relative;
    z-index: 2;
    background: rgba(22, 27, 46, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    max-width: 440px;
    box-shadow: var(--shadow);
}

.locked-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-top: 16px;
}

.locked-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.6;
}

.locked-brand {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* ── Upload Progress ─────────────────────────────────────────────────────── */
.upload-progress {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.upload-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
#uploadFileName {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.upload-progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: 3px;
    transition: width 0.2s ease;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Checkbox ────────────────────────────────────────────────────────────── */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .header { padding: 12px 16px; }
    .main-content { padding: 16px; }
    .modal-meta { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
}

/* ── Spin animation ──────────────────────────────────────────────────────── */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinning .spin-icon {
    animation: spin 1s linear infinite;
}
