/* ============================================
   RBILL - Router Billing System
   Original Design - Industrial Dark Theme
   ============================================ */

:root {
    --rb-bg: #0f1117;
    --rb-surface: #181b24;
    --rb-card: #1e2230;
    --rb-border: #2a2e3d;
    --rb-text: #e4e6ed;
    --rb-text-dim: #8b90a0;
    --rb-accent: #00c896;
    --rb-accent-hover: #00e6ac;
    --rb-accent-bg: rgba(0, 200, 150, 0.08);
    --rb-danger: #f0475c;
    --rb-danger-bg: rgba(240, 71, 92, 0.08);
    --rb-warn: #f0a030;
    --rb-warn-bg: rgba(240, 160, 48, 0.08);
    --rb-info: #3a8fd4;
    --rb-info-bg: rgba(58, 143, 212, 0.08);
    --rb-radius: 8px;
    --rb-shadow: 0 2px 12px rgba(0,0,0,0.3);
    --rb-font: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --rb-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    --rb-sidebar-w: 240px;
    --rb-topbar-h: 56px;
}

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

body {
    font-family: var(--rb-font);
    background: var(--rb-bg);
    color: var(--rb-text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

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

/* ============ LAYOUT ============ */

.rb-wrapper {
    display: flex;
    min-height: 100vh;
}

.rb-sidebar {
    width: var(--rb-sidebar-w);
    background: var(--rb-surface);
    border-right: 1px solid var(--rb-border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}

.rb-sidebar-brand {
    height: var(--rb-topbar-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--rb-border);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 1px;
    gap: 10px;
}

.rb-sidebar-brand .brand-icon {
    width: 32px; height: 32px;
    background: var(--rb-accent);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #0f1117;
    font-weight: 900;
    font-size: 14px;
}

.rb-sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.rb-nav-section {
    padding: 8px 20px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--rb-text-dim);
    font-weight: 600;
}

.rb-nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--rb-text-dim);
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 13px;
}

.rb-nav-item:hover {
    background: rgba(255,255,255,0.03);
    color: var(--rb-text);
}

.rb-nav-item.active {
    background: var(--rb-accent-bg);
    color: var(--rb-accent);
    border-left-color: var(--rb-accent);
    font-weight: 600;
}

.rb-nav-item i { width: 18px; text-align: center; font-size: 15px; }

.rb-main {
    flex: 1;
    margin-left: var(--rb-sidebar-w);
    display: flex;
    flex-direction: column;
}

/* ============ TOPBAR ============ */

.rb-topbar {
    height: var(--rb-topbar-h);
    background: var(--rb-surface);
    border-bottom: 1px solid var(--rb-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.rb-topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.rb-topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.rb-router-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--rb-accent-bg);
    border: 1px solid rgba(0,200,150,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--rb-accent);
    font-weight: 600;
}

.rb-router-badge .dot {
    width: 7px; height: 7px;
    background: var(--rb-accent);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.rb-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--rb-text);
    font-size: 20px;
    cursor: pointer;
}

/* ============ CONTENT ============ */

.rb-content {
    padding: 24px;
    flex: 1;
}

.rb-page-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.rb-page-title i { color: var(--rb-accent); }

/* ============ CARDS ============ */

.rb-card {
    background: var(--rb-card);
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-radius);
    margin-bottom: 20px;
    box-shadow: var(--rb-shadow);
}

.rb-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--rb-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 14px;
}

.rb-card-body {
    padding: 20px;
}

.rb-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--rb-border);
}

/* ============ STAT BOXES ============ */

.rb-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.rb-stat-box {
    background: var(--rb-card);
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-radius);
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--rb-shadow);
}

.rb-stat-info h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--rb-text-dim);
    font-weight: 600;
    margin-bottom: 4px;
}

.rb-stat-info .stat-val {
    font-size: 26px;
    font-weight: 800;
    font-family: var(--rb-mono);
}

.rb-stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.rb-stat-icon.green { background: var(--rb-accent-bg); color: var(--rb-accent); }
.rb-stat-icon.red { background: var(--rb-danger-bg); color: var(--rb-danger); }
.rb-stat-icon.blue { background: var(--rb-info-bg); color: var(--rb-info); }
.rb-stat-icon.yellow { background: var(--rb-warn-bg); color: var(--rb-warn); }

/* ============ TABLE ============ */

.rb-table-wrap {
    overflow-x: auto;
    max-height: 70vh;
    overflow-y: auto;
}

.rb-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
    font-size: 13px;
}

.rb-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.rb-table thead th {
    background: var(--rb-surface);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--rb-text-dim);
    border-bottom: 2px solid var(--rb-border);
    cursor: pointer;
    user-select: none;
}

.rb-table thead th:hover { color: var(--rb-accent); }

.rb-table tbody tr {
    border-bottom: 1px solid var(--rb-border);
    transition: background 0.15s;
}

.rb-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.rb-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
}

.rb-table .col-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

/* ============ BUTTONS ============ */

.rb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--rb-font);
    text-decoration: none;
    white-space: nowrap;
}

.rb-btn i { font-size: 13px; }

.rb-btn-primary {
    background: var(--rb-accent);
    color: #0f1117;
}
.rb-btn-primary:hover { background: var(--rb-accent-hover); color: #0f1117; }

.rb-btn-danger {
    background: var(--rb-danger);
    color: #fff;
}
.rb-btn-danger:hover { background: #ff5a6e; color: #fff; }

.rb-btn-warn {
    background: var(--rb-warn);
    color: #0f1117;
}
.rb-btn-warn:hover { background: #fbb040; }

.rb-btn-outline {
    background: transparent;
    border-color: var(--rb-border);
    color: var(--rb-text);
}
.rb-btn-outline:hover { border-color: var(--rb-accent); color: var(--rb-accent); }

.rb-btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.rb-btn-xs {
    padding: 3px 8px;
    font-size: 11px;
}

.rb-btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ============ FORMS ============ */

.rb-form-group {
    margin-bottom: 16px;
}

.rb-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--rb-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.rb-input, .rb-select {
    width: 100%;
    padding: 9px 14px;
    background: var(--rb-bg);
    border: 1px solid var(--rb-border);
    border-radius: 6px;
    color: var(--rb-text);
    font-size: 13px;
    font-family: var(--rb-font);
    transition: border 0.2s;
    outline: none;
}

.rb-input:focus, .rb-select:focus {
    border-color: var(--rb-accent);
    box-shadow: 0 0 0 3px rgba(0,200,150,0.1);
}

.rb-input::placeholder { color: var(--rb-text-dim); }

.rb-select { cursor: pointer; }

.rb-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.rb-form-inline {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.rb-input-group {
    display: flex;
}

.rb-input-group .rb-input {
    border-radius: 6px 0 0 6px;
}

.rb-input-group .rb-input-append {
    padding: 9px 14px;
    background: var(--rb-surface);
    border: 1px solid var(--rb-border);
    border-left: none;
    border-radius: 0 6px 6px 0;
    color: var(--rb-text-dim);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.rb-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.rb-checkbox input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--rb-accent);
}

/* ============ BADGES ============ */

.rb-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.rb-badge-green { background: var(--rb-accent-bg); color: var(--rb-accent); border: 1px solid rgba(0,200,150,0.2); }
.rb-badge-red { background: var(--rb-danger-bg); color: var(--rb-danger); border: 1px solid rgba(240,71,92,0.2); }
.rb-badge-yellow { background: var(--rb-warn-bg); color: var(--rb-warn); border: 1px solid rgba(240,160,48,0.2); }
.rb-badge-blue { background: var(--rb-info-bg); color: var(--rb-info); border: 1px solid rgba(58,143,212,0.2); }
.rb-badge-gray { background: rgba(139,144,160,0.1); color: var(--rb-text-dim); border: 1px solid rgba(139,144,160,0.2); }

/* ============ FLASH MESSAGES ============ */

.flash-msg {
    padding: 12px 18px;
    border-radius: 6px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    animation: flash-in 0.3s ease;
}

@keyframes flash-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.flash-ok { background: var(--rb-accent-bg); border: 1px solid rgba(0,200,150,0.2); color: var(--rb-accent); }
.flash-err { background: var(--rb-danger-bg); border: 1px solid rgba(240,71,92,0.2); color: var(--rb-danger); }
.flash-info { background: var(--rb-info-bg); border: 1px solid rgba(58,143,212,0.2); color: var(--rb-info); }

.flash-close { cursor: pointer; font-size: 18px; margin-left: 12px; opacity: 0.7; }
.flash-close:hover { opacity: 1; }

/* ============ MODAL ============ */

.rb-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s;
}

.rb-modal-overlay.show { opacity: 1; visibility: visible; }

.rb-modal {
    background: var(--rb-card);
    border: 1px solid var(--rb-border);
    border-radius: 10px;
    width: 500px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    transform: translateY(20px);
    transition: transform 0.25s;
}

.rb-modal-overlay.show .rb-modal { transform: translateY(0); }

.rb-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--rb-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

.rb-modal-close {
    background: none; border: none;
    color: var(--rb-text-dim);
    font-size: 20px;
    cursor: pointer;
}

.rb-modal-body { padding: 20px; }
.rb-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--rb-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============ VOUCHER PRINT ============ */

.voucher-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px;
}

.voucher-card {
    border: 1px dashed #999;
    padding: 12px;
    font-size: 12px;
    font-family: 'Arial', sans-serif;
    color: #000;
    background: #fff;
    page-break-inside: avoid;
}

.voucher-card .v-header {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #333;
    padding-bottom: 6px;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 13px;
}

.voucher-card .v-header img { height: 24px; }

.voucher-card .v-creds {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.voucher-card .v-creds .v-field {
    flex: 1;
    text-align: center;
}

.voucher-card .v-creds .v-label {
    font-size: 10px;
    color: #666;
}

.voucher-card .v-creds .v-value {
    font-weight: 700;
    font-size: 14px;
    border: 1px solid #333;
    padding: 3px;
    margin-top: 2px;
}

.voucher-card .v-info {
    font-size: 10px;
    text-align: center;
    border-top: 1px solid #333;
    padding-top: 4px;
    font-weight: 700;
}

.voucher-card .v-footer {
    font-size: 9px;
    text-align: center;
    color: #666;
    margin-top: 4px;
}

/* ============ GRID HELPERS ============ */

.rb-grid { display: grid; gap: 20px; }
.rb-grid-2 { grid-template-columns: 1fr 1fr; }
.rb-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.rb-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-accent { color: var(--rb-accent); }
.text-danger { color: var(--rb-danger); }
.text-warn { color: var(--rb-warn); }
.text-dim { color: var(--rb-text-dim); }
.text-mono { font-family: var(--rb-mono); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }

/* ============ LOADING SPINNER ============ */

.rb-spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid var(--rb-border);
    border-top-color: var(--rb-accent);
    border-radius: 50%;
    animation: rb-spin 0.7s linear infinite;
}

@keyframes rb-spin {
    to { transform: rotate(360deg); }
}

/* ============ SEARCH / FILTER ============ */

.rb-search-box {
    position: relative;
}

.rb-search-box input {
    padding-left: 36px;
}

.rb-search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--rb-text-dim);
    font-size: 14px;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
    .rb-sidebar { transform: translateX(-100%); }
    .rb-sidebar.open { transform: translateX(0); }
    .rb-main { margin-left: 0; }
    .rb-menu-toggle { display: block; }
    .rb-grid-2, .rb-grid-3, .rb-grid-4 { grid-template-columns: 1fr; }
    .rb-stats { grid-template-columns: 1fr 1fr; }
    .voucher-grid { grid-template-columns: 1fr; }
    .rb-form-row { grid-template-columns: 1fr; }
}

@media print {
    .rb-sidebar, .rb-topbar, .rb-btn, .flash-msg { display: none !important; }
    .rb-main { margin: 0; }
    .rb-content { padding: 0; }
    .voucher-card { border: 1px dashed #000; }
    body { background: #fff; color: #000; }
}

/* ========== THEME: LIGHT ========== */
[data-theme="light"] {
    --rb-bg: #f0f2f5;
    --rb-surface: #ffffff;
    --rb-card: #ffffff;
    --rb-border: #dde1e8;
    --rb-text: #1a1d26;
    --rb-text-dim: #6b7280;
    --rb-accent: #00a67d;
    --rb-accent-hover: #00c896;
    --rb-accent-bg: rgba(0, 166, 125, 0.08);
    --rb-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
[data-theme="light"] .rb-sidebar { background: #1e2230; }
[data-theme="light"] .rb-sidebar .rb-nav-item,
[data-theme="light"] .rb-sidebar .rb-nav-section,
[data-theme="light"] .rb-sidebar-brand span { color: #e4e6ed; }
[data-theme="light"] .rb-sidebar .rb-nav-item:hover { background: rgba(255,255,255,0.06); }
[data-theme="light"] .rb-sidebar .rb-nav-item.active { background: var(--rb-accent-bg); color: var(--rb-accent); }
[data-theme="light"] .rb-table th { background: #f0f2f5; color: #1a1d26; }

/* ========== THEME: BLUE DARK ========== */
[data-theme="blue"] {
    --rb-bg: #0a0e1a;
    --rb-surface: #111827;
    --rb-card: #1a2235;
    --rb-border: #2a3450;
    --rb-accent: #3b82f6;
    --rb-accent-hover: #60a5fa;
    --rb-accent-bg: rgba(59, 130, 246, 0.08);
}

/* ========== THEME: MIDNIGHT GREEN ========== */
[data-theme="green"] {
    --rb-bg: #0a1210;
    --rb-surface: #111f1b;
    --rb-card: #162a24;
    --rb-border: #1e3d33;
    --rb-accent: #10b981;
    --rb-accent-hover: #34d399;
    --rb-accent-bg: rgba(16, 185, 129, 0.08);
}

/* ========== THEME: PURPLE ========== */
[data-theme="purple"] {
    --rb-bg: #110e1a;
    --rb-surface: #1a1527;
    --rb-card: #231e35;
    --rb-border: #342a50;
    --rb-accent: #a855f7;
    --rb-accent-hover: #c084fc;
    --rb-accent-bg: rgba(168, 85, 247, 0.08);
}
