/* ============================================
   Painel IPTV — Dark Theme Stylesheet
   ============================================ */

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111118;
    --bg-card: #16182a;
    --bg-card-hover: #1c1e35;
    --bg-input: #1a1c2e;
    --bg-header: #0d0d14;

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b7b;

    --accent-purple: #7c3aed;
    --accent-purple-hover: #6d28d9;
    --accent-purple-light: rgba(124, 58, 237, 0.15);
    --accent-red: #ef4444;
    --accent-red-hover: #dc2626;
    --accent-green: #22c55e;
    --accent-green-dark: #16a34a;
    --accent-yellow: #eab308;
    --accent-orange: #f97316;

    --border-color: rgba(255, 255, 255, 0.08);
    --border-card: rgba(255, 255, 255, 0.06);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

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

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

img { max-width: 100%; height: auto; }

/* ============ Utilities ============ */
.optional { color: var(--text-muted); font-size: 0.85rem; }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-purple);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-purple-hover); }

.btn-generate {
    background: var(--accent-red);
    color: #fff;
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}
.btn-generate:hover:not(:disabled) { background: var(--accent-red-hover); }

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

.btn-whatsapp {
    background: var(--accent-green);
    color: #fff;
}
.btn-whatsapp:hover { background: var(--accent-green-dark); }

.btn-google {
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
    justify-content: center;
}
.btn-google:hover { background: #f5f5f5; color: #333; }

.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 28px; font-size: 1.1rem; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: var(--accent-red-hover); }

/* ============ Header ============ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
}
.header-logo img { width: 36px; height: 36px; border-radius: 50%; }

.header-user { position: relative; }

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: background var(--transition);
}
.user-dropdown-toggle:hover { background: rgba(255,255,255,0.05); }

.user-avatar { width: 32px; height: 32px; border-radius: 50%; }

.user-avatar-placeholder {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent-purple);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
}

.user-dropdown-menu {
    display: none;
    position: absolute;
    right: 0; top: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 160px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 200;
}
.user-dropdown.open .user-dropdown-menu { display: block; }
.user-dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text-primary);
    transition: background var(--transition);
}
.user-dropdown-menu a:hover { background: rgba(255,255,255,0.05); }

/* ============ Main Content ============ */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    min-height: calc(100vh - 130px);
}

/* ============ Footer ============ */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
}

/* ============ Flash Messages ============ */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
}
.flash-success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); color: var(--accent-green); }
.flash-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: var(--accent-red); }
.flash-warning { background: rgba(234,179,8,0.15); border: 1px solid rgba(234,179,8,0.3); color: var(--accent-yellow); }
.flash-close {
    background: none; border: none; color: inherit;
    cursor: pointer; font-size: 1.2rem; padding: 0 4px;
}

/* ============ Landing Page ============ */
.landing-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.landing-container {
    max-width: 700px;
    margin: 40px auto;
    padding: 0 20px;
    flex: 1;
}

.landing-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    padding: 40px;
    text-align: center;
}

.landing-icon { color: var(--accent-purple); margin-bottom: 20px; }

.landing-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.landing-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 24px;
}

.landing-hero {
    margin: 24px 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.landing-hero img { width: 100%; }

.landing-steps {
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 24px 0;
}
.landing-steps h2 { font-size: 1.1rem; margin-bottom: 16px; }
.landing-steps ol { padding-left: 24px; }
.landing-steps li {
    color: var(--text-secondary);
    padding: 6px 0;
    font-size: 0.95rem;
}

/* ============ Auth Pages ============ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #e8ecf4 0%, #d5dbe8 100%);
}

.auth-container { width: 100%; max-width: 420px; padding: 20px; }

.auth-card {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    color: #333;
}

.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}
.auth-logo img { width: 80px; height: 80px; border-radius: 50%; margin-bottom: 12px; }
.auth-logo h1 { font-size: 1.4rem; color: #1a1a1a; }

.auth-subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.auth-form .form-group { margin-bottom: 16px; }
.auth-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}
.auth-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: border-color var(--transition);
    background: #fafafa;
    color: #333;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--accent-purple);
    background: #fff;
}

.auth-form .btn { margin-top: 8px; }

.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: #999;
    font-size: 0.85rem;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}
.auth-divider span { padding: 0 12px; }

.auth-link {
    text-align: center;
    margin-top: 20px;
    color: #666;
    font-size: 0.9rem;
}
.auth-link a { color: var(--accent-purple); font-weight: 600; }

.auth-card .flash { font-size: 0.85rem; }
.auth-card .flash-error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.2); }
.auth-card .flash-success { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.2); }

/* ============ Dashboard ============ */
.dashboard-container { max-width: 1100px; margin: 0 auto; }

.dashboard-header-section { text-align: center; margin-bottom: 24px; }

.badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-purple { background: var(--accent-purple-light); color: var(--accent-purple); border: 1px solid rgba(124,58,237,0.3); }

.dashboard-title { font-size: 2.2rem; font-weight: 800; margin: 12px 0 4px; }
.dashboard-subtitle { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 20px; }

.dashboard-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============ Cooldown Alert ============ */
.cooldown-alert {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(234, 179, 8, 0.08);
    border: 1px solid rgba(234, 179, 8, 0.25);
    border-radius: var(--radius-lg);
    margin: 20px 0;
}
.cooldown-icon { color: var(--accent-yellow); flex-shrink: 0; }
.cooldown-text { flex: 1; }
.cooldown-text strong { display: block; font-size: 0.95rem; }
.cooldown-text span { color: var(--text-secondary); font-size: 0.85rem; }
.cooldown-timer { font-size: 1.3rem; font-weight: 700; color: var(--accent-yellow); margin-top: 4px; letter-spacing: 2px; }
.cooldown-info { color: var(--text-muted); flex-shrink: 0; }

/* ============ Platforms Grid ============ */
.platforms-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 24px 0;
}

@media (max-width: 1024px) { .platforms-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .platforms-grid { grid-template-columns: 1fr; } }

/* ============ Platform Card ============ */
.platform-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.platform-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.card-adult::before { background: linear-gradient(90deg, var(--accent-red), var(--accent-orange)); }
.card-clean::before { background: linear-gradient(90deg, var(--accent-green), #34d399); }

.platform-card:hover { border-color: rgba(255,255,255,0.12); transform: translateY(-2px); }

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

.card-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
}
.card-icon-tv { color: var(--accent-red); background: rgba(239,68,68,0.12); }
.card-icon-monitor { color: var(--accent-purple); background: var(--accent-purple-light); }
.card-icon-smartphone { color: var(--accent-green); background: rgba(34,197,94,0.12); }

.card-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-adult { background: rgba(239,68,68,0.15); color: var(--accent-red); border: 1px solid rgba(239,68,68,0.3); }
.badge-clean { background: rgba(34,197,94,0.15); color: var(--accent-green); border: 1px solid rgba(34,197,94,0.3); }

.card-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.card-devices { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 16px; }

.card-footer { display: flex; align-items: center; justify-content: space-between; }
.card-duration { color: var(--text-muted); font-size: 0.8rem; }

.dashboard-note {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px 0;
}

/* ============ Modal ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 8px;
}
.modal-header h2 { font-size: 1.3rem; }
.modal-close {
    background: none; border: none;
    color: var(--text-muted); font-size: 1.6rem;
    cursor: pointer; padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }

.modal-subtype {
    padding: 0 24px 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.modal-body {
    padding: 0 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-body pre {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 20px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-secondary);
    max-height: 400px;
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    justify-content: center;
}

.modal-loading {
    text-align: center;
    padding: 48px 32px;
}
.modal-loading p { color: var(--text-secondary); margin-top: 16px; }

/* ============ Spinner ============ */
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ History Page ============ */
.history-header { margin-bottom: 24px; }
.history-header h1 { font-size: 1.6rem; font-weight: 700; }
.history-header p { color: var(--text-secondary); font-size: 0.9rem; }
.history-back {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-secondary); margin-bottom: 8px;
    font-size: 0.9rem;
}
.history-back:hover { color: var(--text-primary); }

.history-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.history-filters input,
.history-filters select {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
}
.history-filters input { flex: 1; min-width: 200px; }
.history-filters select { min-width: 120px; }
.history-filters input:focus,
.history-filters select:focus {
    outline: none;
    border-color: var(--accent-purple);
}

.test-list { display: flex; flex-direction: column; gap: 8px; }

.test-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
}
.test-item:hover { border-color: rgba(255,255,255,0.12); background: var(--bg-card-hover); }

.test-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: rgba(239,68,68,0.12);
    color: var(--accent-red);
    flex-shrink: 0;
}

.test-info { flex: 1; }
.test-info strong { display: flex; align-items: center; gap: 8px; }
.test-info .test-date { color: var(--text-muted); font-size: 0.8rem; }
.test-status {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-left: 4px;
}
.test-status.active { background: var(--accent-green); }
.test-status.expired { background: var(--text-muted); }
.test-status.failed { background: var(--accent-red); }

.test-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-renew {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--accent-purple);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transition);
    cursor: pointer;
}
.btn-renew:hover {
    background: var(--accent-purple-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}
.btn-renew svg { flex-shrink: 0; }

/* ============ Forms (General) ============ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--accent-purple); }

textarea.form-control { min-height: 120px; resize: vertical; font-family: inherit; }
select.form-control { cursor: pointer; }

/* ============ Chat Widget ============ */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-purple);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    z-index: 500;
    transition: all var(--transition);
}
.chat-widget:hover {
    background: var(--accent-purple-hover);
    transform: scale(1.05);
    color: #fff;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
    .main-content { padding: 16px; }
    .header { padding: 10px 16px; }
    .landing-card { padding: 24px; }
    .landing-title { font-size: 1.5rem; }
    .dashboard-title { font-size: 1.6rem; }
    .modal { max-width: 95vw; }
    .modal-actions { flex-direction: column; }
    .history-filters { flex-direction: column; }
    .test-item { flex-wrap: wrap; gap: 10px; }
    .test-actions { width: 100%; justify-content: flex-start; }
}
