/* ═══════════════════════════════════════════════════════════════
   CameraAiPro - Web Dashboard Styles
   ═══════════════════════════════════════════════════════════════ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ─── Header ──────────────────────────────────────────────────── */

.header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    padding: 28px 0;
    box-shadow: var(--shadow-md);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2rem;
}

.logo h1 {
    font-size: 1.6rem;
    font-weight: 700;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.85;
}

/* ─── Tabs ────────────────────────────────────────────────────── */

.tabs {
    display: flex;
    gap: 4px;
    margin: 24px 0 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 4px;
    box-shadow: var(--shadow);
}

.tab {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.tab:hover {
    background: var(--bg);
    color: var(--text);
}

.tab.active {
    background: var(--primary);
    color: white;
}

/* ─── Tab Content ─────────────────────────────────────────────── */

.tab-content {
    display: none;
    padding: 24px 0;
}

.tab-content.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 1.2rem;
}

/* ─── Cards ───────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.camera-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.camera-info {
    flex: 1;
    min-width: 0;
}

.camera-info h3 {
    font-size: 1rem;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.camera-info .rtsp-url {
    font-size: 0.8rem;
    color: var(--text-light);
    font-family: 'Consolas', monospace;
    word-break: break-all;
}

.camera-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.active {
    background: #dcfce7;
    color: #16a34a;
}

.status-badge.inactive {
    background: #fee2e2;
    color: #dc2626;
}

/* ─── Forms ───────────────────────────────────────────────────── */

.form-card {
    border-left: 4px solid var(--primary);
}

.form-card h3 {
    margin-bottom: 16px;
    font-size: 1.05rem;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: var(--text-light);
    font-size: 0.8rem;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500 !important;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.range-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-group input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
    height: 6px;
}

.range-value {
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
    min-width: 45px;
    text-align: right;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ─── Buttons ─────────────────────────────────────────────────── */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1.5px solid var(--danger);
    padding: 6px 14px;
    font-size: 0.85rem;
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-edit {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-edit:hover {
    background: var(--primary);
    color: white;
}

/* ─── Info Box ────────────────────────────────────────────────── */

.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    font-size: 0.88rem;
}

.info-box strong {
    display: block;
    margin-bottom: 8px;
}

.info-box ol {
    padding-left: 20px;
}

.info-box li {
    margin-bottom: 4px;
}

.info-box code {
    background: #dbeafe;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* ─── Status Message ──────────────────────────────────────────── */

.status-message {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-message.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.status-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* ─── Toast ───────────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: var(--radius);
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
    max-width: 400px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.hidden { opacity: 0; transform: translateY(20px); pointer-events: none; }

/* ─── Loading ─────────────────────────────────────────────────── */

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-light);
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ─── Hidden ──────────────────────────────────────────────────── */

.hidden {
    display: none !important;
}

/* ─── Footer ──────────────────────────────────────────────────── */

.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 40px;
}

/* ─── Login Overlay ───────────────────────────────────────────── */

.login-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 60%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .logo-icon {
    font-size: 3rem;
}

.login-logo h1 {
    font-size: 1.8rem;
    color: var(--primary);
    margin: 8px 0 4px;
}

.login-logo p {
    color: var(--text-light);
    font-size: 0.9rem;
}

#auth-title {
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.login-card .form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.login-card .form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-full {
    width: 100%;
    padding: 12px;
}

.btn-google {
    background: #fff;
    color: #333;
    border: 1.5px solid var(--border);
    font-weight: 600;
}

.btn-google:hover {
    background: #f8f8f8;
    border-color: #999;
}

.auth-divider {
    text-align: center;
    margin: 16px 0;
    position: relative;
}

.auth-divider span {
    background: var(--bg-card);
    padding: 0 12px;
    color: var(--text-light);
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.auth-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.auth-toggle a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* ─── User Info Header ────────────────────────────────────────── */

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-email {
    color: rgba(255,255,255,0.85);
    font-size: 0.85rem;
}

.btn-logout {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.25);
}

/* ─── Plan Badges ─────────────────────────────────────────────── */

.plan-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.plan-badge-lg {
    font-size: 1rem;
    padding: 6px 20px;
}

.plan-badge { background: #e2e8f0; color: #475569; }
.plan-trial { background: #ffedd5; color: #c2410c; }
.plan-basic { background: #dbeafe; color: #1d4ed8; }
.plan-pro { background: #fef3c7; color: #b45309; }
.plan-enterprise { background: #ede9fe; color: #7c3aed; }

/* ─── License Tab ─────────────────────────────────────────────── */

.license-card {
    border-left: 4px solid var(--primary);
}

.license-plan-display {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 12px;
}

.license-stats {
    font-size: 0.95rem;
}

.license-key-code {
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    letter-spacing: 2px;
}

.plan-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.plan-table th, .plan-table td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.plan-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-light);
    font-weight: 600;
}

.code-block {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px 16px;
    border-radius: 8px;
    font-family: 'Consolas', monospace;
    font-size: 0.9rem;
}

.code-block .btn {
    flex-shrink: 0;
}

/* ─── Responsive ──────────────────────────────────────────────── */

@media (max-width: 640px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .user-info {
        flex-wrap: wrap;
        justify-content: center;
    }

    .tabs {
        flex-direction: column;
    }

    .camera-card {
        flex-direction: column;
        align-items: stretch;
    }

    .camera-actions {
        justify-content: flex-end;
    }

    .section-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .form-actions {
        flex-direction: column;
    }

    .login-card {
        margin: 16px;
        padding: 28px 20px;
    }

    .license-plan-display {
        flex-direction: column;
        align-items: flex-start;
    }

    .code-block {
        flex-direction: column;
        align-items: stretch;
    }
}
