/* =====================================================
   WHITE-LABEL TTS — Giao diện
   Đại lý có thể tùy chỉnh file này
   ===================================================== */

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

:root {
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-glow: rgba(124, 58, 237, 0.3);
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #16162a;
    --text: #e4e4e7;
    --text-muted: #a1a1aa;
    --border: rgba(255,255,255,0.08);
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ─── Header ─── */
.header {
    background: rgba(26,26,46,0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.header-brand img {
    height: 32px;
    border-radius: 6px;
}

.header-brand h1 {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.85rem;
}

.header-user .quota {
    background: rgba(124,58,237,0.15);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    color: #a78bfa;
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all .2s;
}
.btn-logout:hover {
    border-color: var(--error);
    color: var(--error);
}

/* ─── Container ─── */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
}

.container-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

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

input, textarea, select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border .2s;
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--error); color: white; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ─── Auth Page ─── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(ellipse at top, rgba(124,58,237,0.15), transparent 60%);
}

.auth-box {
    width: 100%;
    max-width: 420px;
}

.auth-box .card {
    padding: 32px;
}

.auth-box h1 {
    text-align: center;
    font-size: 1.6rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all .2s;
}

.auth-tab.active {
    background: var(--primary);
    color: white;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.auth-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--error);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    margin-bottom: 16px;
    display: none;
}

/* ─── Voice Grid ─── */
.voice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
}

.voice-item {
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all .2s;
}

.voice-item:hover {
    border-color: rgba(124,58,237,0.5);
}

.voice-item.selected {
    border-color: var(--primary);
    background: rgba(124,58,237,0.08);
}

.voice-item .name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.voice-item .labels {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ─── Audio Player ─── */
.audio-player-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    background: var(--bg-input);
    padding: 10px 14px;
    border-radius: 10px;
}

.player-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: .2s;
}
.player-btn:hover { transform: scale(1.1); }

.player-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    border: none;
    padding: 0;
}
.player-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.player-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 80px;
    text-align: right;
}

/* ─── History ─── */
.history-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.history-header .time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-completed { color: var(--success); font-weight: 700; font-size: 0.8rem; }
.status-pending { color: var(--warning); font-weight: 700; font-size: 0.8rem; }
.status-failed { color: var(--error); font-weight: 700; font-size: 0.8rem; }

/* ─── Admin Table ─── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.data-table tr:hover td {
    background: rgba(124,58,237,0.05);
}

/* ─── Stats ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ─── Modal ─── */
.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;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .container, .container-wide { padding: 12px; }
    .header { padding: 12px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .voice-grid { grid-template-columns: 1fr; }
}

/* ─── Utilities ─── */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.hidden { display: none !important; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ─── Animations ─── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .3s ease; }

@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner-sm {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
