/* ============================================
   Billing Arpha - ISP Billing System
   Custom Stylesheet
   ============================================ */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-rgb: 79, 70, 229;
    
    --sidebar-bg: linear-gradient(180deg, #0f0a3e 0%, #1a1550 40%, #272171 100%);
    --sidebar-width: 260px;
    
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #0ea5e9;
    --info-light: #f0f9ff;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 50px -12px rgba(0,0,0,0.15);
    
    --radius: 12px;
    --radius-lg: 16px;
    --radius-sm: 8px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

a { text-decoration: none; }

/* ============================================
   APP LAYOUT
   ============================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow: hidden;
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.4);
}

.brand-text h5 {
    color: white;
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 0;
    letter-spacing: -0.3px;
}

.brand-text small {
    color: rgba(255,255,255,0.5);
    font-size: 11px;
    font-weight: 400;
}

.sidebar-close {
    color: rgba(255,255,255,0.5);
    font-size: 20px;
    padding: 0;
}

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

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-divider {
    color: rgba(255,255,255,0.3);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 20px 16px 8px;
    text-transform: uppercase;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: rgba(255,255,255,0.6);
    border-radius: 10px;
    transition: var(--transition);
    font-weight: 500;
    font-size: 13.5px;
    position: relative;
}

.nav-item a:hover {
    color: white;
    background: rgba(255,255,255,0.08);
}

.nav-item.active a {
    color: white;
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.35);
}

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

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.company-info small {
    color: rgba(255,255,255,0.35);
    font-size: 11px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    backdrop-filter: blur(4px);
}

/* ============================================
   TOP NAVBAR
   ============================================ */
.top-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.sidebar-toggle {
    color: var(--text-primary);
    font-size: 20px;
    padding: 4px 8px;
    margin-right: 12px;
}

.user-dropdown {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13.5px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* ============================================
   CONTENT AREA
   ============================================ */
.content-area {
    padding: 28px;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 18px 24px;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* Stats Cards */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card.primary::before { background: linear-gradient(90deg, var(--primary), #7c3aed); }
.stat-card.success::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card.warning::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-card.danger::before { background: linear-gradient(90deg, var(--danger), #f87171); }

.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.primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.danger .stat-icon { background: var(--danger-light); color: var(--danger); }

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 4px;
}

/* ============================================
   TABLES
   ============================================ */
.table-card {
    border-radius: var(--radius);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 14px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 13.5px;
}

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

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

/* ============================================
   BADGES
   ============================================ */
.badge-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-aktif {
    background: var(--success-light);
    color: var(--success);
}

.badge-nonaktif {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-method {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-cash { background: #dbeafe; color: #2563eb; }
.badge-transfer { background: #fae8ff; color: #a855f7; }
.badge-qris { background: #ccfbf1; color: #0d9488; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    font-weight: 600;
    font-size: 13px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    letter-spacing: 0.2px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
    transform: translateY(-1px);
}

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

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

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

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

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
}

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

/* ============================================
   FORMS
   ============================================ */
.form-control, .form-select {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    font-size: 13.5px;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.input-group-text {
    background: #f8fafc;
    border: 1.5px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    padding: 14px 18px;
}

.alert-success { background: var(--success-light); color: #065f46; }
.alert-danger { background: var(--danger-light); color: #991b1b; }
.alert-warning { background: var(--warning-light); color: #92400e; }
.alert-info { background: var(--info-light); color: #0c4a6e; }

/* ============================================
   JATUH TEMPO TABLE
   ============================================ */
.jatuh-tempo-row {
    background: #fff7ed !important;
    border-left: 3px solid var(--warning);
}

.jatuh-tempo-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--warning-light);
    color: #b45309;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    animation: pulse-badge 2s infinite;
}

/* ============================================
   CHART CONTAINER
   ============================================ */
.chart-container {
    position: relative;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f0a3e 0%, #1a1550 30%, #272171 60%, #3730a3 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.15), transparent 70%);
    top: -200px;
    right: -200px;
    border-radius: 50%;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.12), transparent 70%);
    bottom: -150px;
    left: -150px;
    border-radius: 50%;
}

.login-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    margin: 0 auto 20px;
    box-shadow: 0 8px 25px rgba(var(--primary-rgb), 0.35);
}

.login-title {
    text-align: center;
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-card .form-control {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 10px;
}

.login-card .btn-primary {
    padding: 12px;
    font-size: 15px;
    border-radius: 10px;
    width: 100%;
    font-weight: 700;
}

/* ============================================
   INVOICE
   ============================================ */
.invoice-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 48px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--primary);
}

.invoice-company h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.invoice-company p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 2px;
}

.invoice-title h3 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    text-align: right;
}

.invoice-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.invoice-info-block h5 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.invoice-table {
    width: 100%;
    margin-bottom: 24px;
}

.invoice-table thead th {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.invoice-table thead th:first-child {
    border-radius: 8px 0 0 0;
}

.invoice-table thead th:last-child {
    border-radius: 0 8px 0 0;
}

.invoice-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13.5px;
}

.invoice-total {
    text-align: right;
    padding-top: 16px;
}

.invoice-total .total-row {
    display: flex;
    justify-content: flex-end;
    gap: 40px;
    padding: 8px 0;
    font-size: 14px;
}

.invoice-total .total-row.grand-total {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    border-top: 2px solid var(--border-color);
    padding-top: 12px;
    margin-top: 8px;
}

.invoice-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
}

/* ============================================
   DATATABLE OVERRIDES
   ============================================ */
.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 6px 12px;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 4px 8px;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    font-size: 13px;
    color: var(--text-secondary);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
}

/* ============================================
   UTILITIES
   ============================================ */
.text-primary-custom { color: var(--primary) !important; }
.bg-primary-light { background: var(--primary-light) !important; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h5 {
    color: var(--text-secondary);
    font-weight: 600;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 13px;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .sidebar, .top-navbar, .btn, .no-print {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
    }
    .content-area {
        padding: 0 !important;
    }
    .invoice-container {
        box-shadow: none;
        padding: 20px;
    }
    body {
        background: white;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .sidebar-overlay.show {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .content-area {
        padding: 16px;
    }
    .top-navbar {
        padding: 12px 16px;
    }
    .stat-value {
        font-size: 22px;
    }
    .invoice-container {
        padding: 24px;
    }
    .invoice-header {
        flex-direction: column;
        gap: 16px;
    }
    .invoice-title h3 {
        text-align: left;
    }
    .invoice-info {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575.98px) {
    .login-card {
        margin: 16px;
        padding: 32px 24px;
    }
}
