/* ============================================
   TV4One IPTV Panel - Custom CSS
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1a1f2e;
    --sidebar-hover: #2d3548;
    --sidebar-active: #3b82f6;
    --topbar-height: 60px;
    --primary-color: #3b82f6;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ---- Layout ---- */
body {
    background-color: #f0f2f5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9rem;
    color: #2d3436;
    overflow-x: hidden;
}

.wrapper {
    min-height: 100vh;
    position: relative;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    overflow: hidden;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

/* The nav list is the scroll region, not the outer nav.
   flex: 1 1 0 + min-height: 0 allows a flex item to shrink
   below its content size so overflow-y: auto actually fires. */
.sidebar > ul.nav {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex-wrap: nowrap;      /* Bootstrap .nav sets flex-wrap:wrap; this prevents column wrapping */
    flex-direction: column; /* belt-and-suspenders alongside Bootstrap's .flex-column */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}

.sidebar-brand {
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand .brand-text {
    color: #f8fafc;
}

.sidebar-user {
    background: rgba(255,255,255,0.03);
}

.avatar-circle {
    width: 34px;
    height: 34px;
    background: var(--sidebar-active);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar .nav-link {
    color: #94a3b8;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 2px;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.sidebar .nav-link:hover {
    color: #f1f5f9;
    background: var(--sidebar-hover);
}

.sidebar .nav-link.active {
    color: #fff;
    background: var(--sidebar-active);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(59,130,246,0.35);
}

.sidebar .nav-link i {
    width: 18px;
    text-align: center;
}

.nav-section-label {
    color: #64748b;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    padding-top: 0.5rem;
    display: block;
}

.x-small {
    font-size: 0.75rem;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
}

/* ---- Content Area ---- */
.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* ---- Cards ---- */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #f1f5f9;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* Stats Cards */
.stat-card {
    border-radius: 12px;
    padding: 1.25rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.2rem;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bg-stat-blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.bg-stat-green  { background: linear-gradient(135deg, #22c55e, #16a34a); }
.bg-stat-orange { background: linear-gradient(135deg, #f97316, #ea580c); }
.bg-stat-purple { background: linear-gradient(135deg, #a855f7, #7c3aed); }

/* ---- Tables ---- */
.table-responsive {
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.table thead th {
    background: #f8fafc;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    padding: 0.75rem 1rem;
}

.table tbody td {
    padding: 0.7rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* ---- Badges ---- */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

/* ---- Forms ---- */
.form-control, .form-select {
    border-radius: 8px;
    border-color: #e2e8f0;
    font-size: 0.875rem;
    padding: 0.5rem 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.form-label {
    font-weight: 600;
    font-size: 0.83rem;
    color: #374151;
    margin-bottom: 0.35rem;
}

/* ---- Buttons ---- */
.btn {
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.45rem 1rem;
    transition: all 0.2s;
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 6px;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* ---- Search/Filter Bar ---- */
.filter-bar {
    background: #fff;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1rem;
}

/* ---- Ticket Thread ---- */
.ticket-message {
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.ticket-message.admin-msg {
    background: #eff6ff;
    border-left: 4px solid var(--primary-color);
}

.ticket-message.customer-msg {
    background: #f0fdf4;
    border-left: 4px solid #22c55e;
}

.ticket-message .msg-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: #64748b;
}

.ticket-message .msg-body {
    white-space: pre-wrap;
    font-size: 0.9rem;
    color: #1e293b;
}

/* ---- M3U Token ---- */
.token-box {
    background: #1e293b;
    color: #a3e635;
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    word-break: break-all;
}

/* ---- Server Status Indicators ---- */
.server-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.server-status-dot.online     { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.server-status-dot.offline    { background: #ef4444; box-shadow: 0 0 6px #ef4444; }
.server-status-dot.maintenance{ background: #f97316; box-shadow: 0 0 6px #f97316; }

/* ---- Alert styles ---- */
.alert {
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
}

/* ---- Progress Bar for connections ---- */
.progress {
    border-radius: 20px;
    height: 8px;
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ---- Trial code list ---- */
.trial-code-item {
    background: #1e293b;
    color: #a3e635;
    font-family: monospace;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 1rem;
    letter-spacing: 0.1em;
}

/* ---- Customer view ---- */
.info-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.1rem;
}

.info-value {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .content-area {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 767.98px) {
    .topbar {
        padding: 0 1rem;
    }

    .content-area {
        padding: 0.75rem;
    }

    .table thead th,
    .table tbody td {
        font-size: 0.8rem;
        padding: 0.5rem 0.6rem;
    }
}

/* ---- Topbar hamburger ---- */
#sidebarToggle {
    display: none;
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    margin-right: 0.75rem;
    border-radius: 6px;
    transition: background 0.2s;
}

#sidebarToggle:hover {
    background: #f1f5f9;
}

@media (max-width: 991.98px) {
    #sidebarToggle {
        display: inline-flex;
        align-items: center;
    }
}

/* ---- Quick action buttons ---- */
.quick-actions .btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    border-radius: 10px;
}

/* ---- Login page ---- */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1f2e 0%, #2d3548 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 2.5rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo i {
    font-size: 3rem;
    color: var(--primary-color);
}

/* ---- Sidebar footer ---- */
.sidebar > ul.nav::-webkit-scrollbar { width: 4px; }
.sidebar > ul.nav::-webkit-scrollbar-track { background: transparent; }
.sidebar > ul.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }
.sidebar > ul.nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); }

.sidebar-footer {
    margin-top: auto;
}
