/* ===== XCIPTV Panel - Professional Theme ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0f1123;
    --bg-secondary: #161836;
    --bg-card: #1c1f3a;
    --bg-card-hover: #222550;
    --border-color: #2a2d52;
    --accent: #6c5ce7;
    --accent-hover: #7f71ed;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --success: #00cec9;
    --warning: #fdcb6e;
    --danger: #ff6b6b;
    --info: #74b9ff;
    --text-primary: #e8e8f0;
    --text-secondary: #8b8ca7;
    --text-muted: #5a5b7a;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Login Page ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
}

.login-bg-pattern {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 206, 201, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(116, 185, 255, 0.05) 0%, transparent 50%);
    z-index: 0;
}

.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    margin: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent), var(--success));
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.login-logo h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.login-logo p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-login:active {
    transform: translateY(0);
}

/* ===== Layout ===== */
.panel-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 24px 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar-logo {
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo .s-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--success));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-logo span {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px 12px 0;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 4px;
}

.page-header p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* ===== Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.stat-card .stat-icon.purple { background: rgba(108,92,231,0.15); color: var(--accent); }
.stat-card .stat-icon.teal { background: rgba(0,206,201,0.15); color: var(--success); }
.stat-card .stat-icon.blue { background: rgba(116,185,255,0.15); color: var(--info); }
.stat-card .stat-icon.orange { background: rgba(253,203,110,0.15); color: var(--warning); }
.stat-card .stat-icon.red { background: rgba(255,107,107,0.15); color: var(--danger); }

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Content Cards ===== */
.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.content-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.content-card-body {
    padding: 24px;
}

/* ===== Tables ===== */
.table-responsive {
    overflow-x: auto;
}

.pro-table {
    width: 100%;
    border-collapse: collapse;
}

.pro-table thead th {
    background: var(--bg-secondary);
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.pro-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(42, 45, 82, 0.5);
    color: var(--text-primary);
    word-wrap: break-word;
}

.pro-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.pro-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: rgba(0, 206, 201, 0.15);
    color: var(--success);
}

.badge-danger {
    background: rgba(255, 107, 107, 0.15);
    color: var(--danger);
}

.badge-warning {
    background: rgba(253, 203, 110, 0.15);
    color: var(--warning);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px var(--accent-glow); color: #fff; }

.btn-success { background: rgba(0,206,201,0.15); color: var(--success); border: 1px solid rgba(0,206,201,0.3); }
.btn-success:hover { background: rgba(0,206,201,0.25); color: var(--success); }

.btn-warning { background: rgba(253,203,110,0.15); color: var(--warning); border: 1px solid rgba(253,203,110,0.3); }
.btn-warning:hover { background: rgba(253,203,110,0.25); color: var(--warning); }

.btn-danger { background: rgba(255,107,107,0.15); color: var(--danger); border: 1px solid rgba(255,107,107,0.3); }
.btn-danger:hover { background: rgba(255,107,107,0.25); color: var(--danger); }

.btn-info { background: rgba(116,185,255,0.15); color: var(--info); border: 1px solid rgba(116,185,255,0.3); }
.btn-info:hover { background: rgba(116,185,255,0.25); color: var(--info); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Forms ===== */
.form-card {
    max-width: 500px;
    margin: 0 auto;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-primary);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 120px; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check-input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.form-check-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ===== Modals ===== */
.modal-content {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg) !important;
}

.modal-header {
    border-bottom: 1px solid var(--border-color) !important;
    padding: 20px 24px;
}

.modal-header h2, .modal-header h5 {
    color: var(--text-primary) !important;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-body {
    color: var(--text-secondary) !important;
    padding: 20px 24px;
}

.modal-footer {
    border-top: 1px solid var(--border-color) !important;
    padding: 16px 24px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 15px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Mobile Toggle ===== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: var(--shadow);
}

/* ===== Sidebar Overlay (mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 99;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
}

/* ===== Mobile Top Bar ===== */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 90;
    align-items: center;
    padding: 0 16px 0 64px;
}

.mobile-topbar .topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Responsive — Tablet (max 1024px) ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    .main-content {
        margin-left: 220px;
        padding: 28px 24px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== Responsive — Mobile (max 768px) ===== */
@media (max-width: 768px) {
    .mobile-toggle {
        display: flex;
    }
    .mobile-topbar {
        display: flex;
    }
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        width: 280px;
        z-index: 100;
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0,0,0,0.5);
    }
    .main-content {
        margin-left: 0;
        padding: 72px 16px 24px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .stat-card {
        padding: 16px;
    }
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
        margin-bottom: 12px;
    }
    .stat-card .stat-value {
        font-size: 22px;
    }
    .stat-card .stat-label {
        font-size: 11px;
    }
    .page-header {
        margin-bottom: 20px;
    }
    .page-header h1 {
        font-size: 20px;
    }
    .page-header p {
        font-size: 13px;
    }
    /* Card header stacks on small */
    .content-card-header {
        flex-wrap: wrap;
        gap: 12px;
        padding: 16px;
    }
    .content-card-body {
        padding: 16px;
    }
    /* Form cards full width */
    .form-card {
        max-width: 100%;
    }
    /* Buttons touch-friendly */
    .btn {
        padding: 12px 20px;
        font-size: 14px;
    }
    .btn-sm {
        padding: 10px 14px;
        font-size: 13px;
    }
    /* Table → card layout on mobile */
    .pro-table thead {
        display: none;
    }
    .pro-table tbody tr {
        display: block;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 14px 16px;
    }
    .pro-table tbody tr:hover {
        background: var(--bg-card-hover);
    }
    .pro-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: 1px solid rgba(42,45,82,0.3);
        font-size: 13px;
    }
    .pro-table tbody td:last-child {
        border-bottom: none;
        padding-top: 10px;
        justify-content: flex-start;
        gap: 8px;
    }
    .pro-table tbody td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        color: var(--text-muted);
        flex-shrink: 0;
        margin-right: 12px;
    }
    .pro-table tbody td[style*="max-width"] {
        max-width: none !important;
        white-space: normal !important;
        word-break: break-all;
    }
    /* Modal */
    .modal-dialog {
        margin: 16px;
    }
    /* Login */
    .login-card {
        padding: 32px 24px;
        margin: 16px;
        border-radius: var(--radius);
    }
    .login-logo .logo-icon {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
    .login-logo h2 {
        font-size: 20px;
    }
}

/* ===== Responsive — Small phones (max 480px) ===== */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .stat-card {
        display: flex;
        align-items: center;
        gap: 16px;
        padding: 14px 16px;
    }
    .stat-card .stat-icon {
        margin-bottom: 0;
        flex-shrink: 0;
    }
    .stat-card .stat-info {
        flex: 1;
    }
    .main-content {
        padding: 64px 12px 20px;
    }
    .page-header h1 {
        font-size: 18px;
    }
    .content-card-header h3 {
        font-size: 14px;
    }
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* ===== Safe area (notch phones) ===== */
@supports (padding: env(safe-area-inset-bottom)) {
    .sidebar-footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
    .main-content {
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card, .content-card {
    animation: fadeIn 0.5s ease forwards;
}

.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.2s; }
.stat-card:nth-child(4) { animation-delay: 0.3s; }

/* ===== Utility ===== */
.text-center { text-align: center; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mt-3 { margin-top: 16px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
