:root {
    --bg-main: #0B0E17;
    --bg-panel: #131722;
    --bg-card: #181C27;
    --bg-section: #1A1F2C;
    --text-main: #E2E8F0;
    --text-muted: #8F9BB3;
    --primary: #3B82F6; /* Blue */
    --primary-hover: #2563EB;
    --secondary: #8B5CF6; /* Purple */
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #0EA5E9;
    --border: #2A3142;
    --radius: 8px;
    --font: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-secondary { color: var(--secondary); }
.text-muted { color: var(--text-muted); }
.text-white { color: white; }
.text-sm { font-size: 0.875rem; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.p-0 { padding: 0 !important; }
.p-4 { padding: 24px; }
.w-100 { width: 100%; }

.border-top { border-top: 1px solid var(--border); }
.justify-center { display: flex; justify-content: center; align-items: center; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    font-family: var(--font);
    font-size: 0.9rem;
}
.btn:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--border); color: white; }
.btn-secondary:hover:not(:disabled) { background: #3f4a62; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: 0.2s;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); color: white; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9rem; color: #cbd5e1; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    padding: 10px 14px;
    background: #0f121b;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: white;
    font-family: var(--font);
    font-size: 0.95rem;
    transition: 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
textarea { resize: vertical; }

.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

code {
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

/* Login Screen */
.login-screen {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-main);
}
.login-box {
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.logo h2 { font-size: 1.5rem; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px;}

/* App Layout */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    background: var(--bg-panel);
    height: 64px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.nav-menu { display: flex; gap: 8px; }
.nav-item {
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: 0.2s;
}
.nav-item:hover, .nav-item.active {
    color: white;
    background: rgba(255,255,255,0.05);
}
.nav-item.active { border-bottom: 2px solid var(--primary); border-radius: 0; background: transparent; }

.main-content {
    flex: 1;
    padding: 32px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.view { display: none; animation: fadeIn 0.3s; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.section-header { margin-bottom: 24px; }
.section-header h1 { font-size: 1.8rem; font-weight: 600; color: white; }
.section-header .subtitle { color: var(--text-muted); margin-top: 4px; }

/* Filter Sections */
.section-box {
    background: var(--bg-section);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.section-title { font-size: 1.1rem; color: white; margin-bottom: 16px; display: flex; align-items: center; gap: 8px;}

/* Checkboxes */
.checkbox-list { display: flex; flex-direction: column; gap: 12px; }
.custom-checkbox {
    display: flex;
    align-items: flex-start;
    position: relative;
    padding-left: 32px;
    cursor: pointer;
    font-size: 0.95rem;
    user-select: none;
}
.custom-checkbox input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }
.checkmark {
    position: absolute; top: 2px; left: 0;
    height: 20px; width: 20px;
    background-color: #0f121b;
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: 0.2s;
}
.custom-checkbox:hover input ~ .checkmark { border-color: var(--primary); }
.custom-checkbox input:checked ~ .checkmark { background-color: var(--primary); border-color: var(--primary); }
.checkmark:after {
    content: ""; position: absolute; display: none;
    left: 6px; top: 2px; width: 5px; height: 10px;
    border: solid white; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.custom-checkbox input:checked ~ .checkmark:after { display: block; }
.cb-text { display: flex; flex-direction: column; }
.cb-text strong { color: white; font-weight: 500; }
.cb-text span { font-size: 0.85rem; color: var(--text-muted); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-grid .custom-checkbox { 
    background: #0f121b;
    border: 1px solid var(--border);
    padding: 12px 12px 12px 40px;
    border-radius: var(--radius);
    align-items: center; 
    margin: 0;
    transition: 0.2s;
}
.media-grid .custom-checkbox:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}
.media-grid .checkmark { top: 50%; transform: translateY(-50%); left: 12px; }

/* Dashboard Widgets */
.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.widget-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.widget-icon {
    font-size: 2rem;
}
.widget-info h4 { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px;}
.widget-info .val { font-size: 1.2rem; font-weight: 600; color: white; }

.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600;
}
.status-badge.online { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.status-badge.offline { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }

/* Rules Table */
.rules-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-x: auto;
}
.rules-table {
    width: 100%;
    border-collapse: collapse;
}
.rules-table th, .rules-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.rules-table th { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;}
.rules-table td { font-size: 0.9rem; }
.rules-table tr:last-child td { border-bottom: none; }
.rules-table .actions { display: flex; gap: 8px; }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
    opacity: 0; pointer-events: none; transition: 0.3s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: 0.3s;
}
.modal-overlay.show .modal-content { transform: translateY(0); }
.modal-header {
    padding: 16px 24px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 1.2rem; display: flex; align-items: center; gap: 8px;}
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 12px;
}

.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: #1e293b; color: white;
    padding: 12px 20px; border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    display: flex; align-items: center; gap: 12px;
    transform: translateY(100px); opacity: 0; transition: 0.3s;
    z-index: 9999;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Responsive Design for Mobile */
@media screen and (max-width: 768px) {
    .topbar {
        padding: 0 16px;
        flex-direction: column;
        height: auto;
        padding-top: 12px;
        padding-bottom: 12px;
        gap: 12px;
    }
    .nav-menu {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 4px;
        justify-content: flex-start;
        /* Hides scrollbar for cleaner look but allows scrolling */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .nav-menu::-webkit-scrollbar {
        display: none;
    }
    .nav-item {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 6px 12px;
    }
    .main-content {
        padding: 16px;
    }
    .form-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .dashboard-widgets {
        grid-template-columns: 1fr;
    }
    .section-box, .card {
        padding: 16px;
    }
    .modal-content {
        margin: 16px;
        width: calc(100% - 32px);
    }
    .modal-header, .modal-footer, .modal-body {
        padding: 16px;
    }
}
