:root {
    --primary: #4361ee;
    --primary-light: #4895ef;
    --secondary: #3f37c9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #0f172a;
    --dark-panel: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(15, 23, 42, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background: linear-gradient(135deg, #020617 0%, #0f172a 100%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: white;
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.2);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-edit { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.btn-edit:hover { background: #3b82f6; color: white; }
.btn-delete { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.btn-delete:hover { background: #ef4444; color: white; }
.btn-whatsapp { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.btn-whatsapp:hover { background: #10b981; color: white; }

/* Login Section */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
    text-align: center;
}

.auth-logo {
    margin-bottom: 30px;
}

.auth-logo i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 10px;
}

.form-group {
    margin-bottom: 20px;
    text-align: right;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-with-icon input, .form-group input, .form-group textarea {
    width: 100%;
    padding: 12px 15px 12px 40px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: white;
    font-size: 15px;
    transition: all 0.3s;
    outline: none;
}
.form-group input, .form-group textarea {
    padding: 12px 15px;
}

.input-with-icon input:focus, .form-group input:focus, .form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.3);
}

.w-100 { width: 100%; }
.hidden { display: none !important; }

/* Dashboard Layout */
.dashboard-wrapper {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    height: calc(100vh - 32px);
    margin: 16px;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
}

.sidebar-header {
    padding: 0 24px 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.sidebar-header i {
    font-size: 24px;
    color: var(--primary);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0 16px;
    gap: 8px;
}

.nav-item {
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s;
    font-weight: 600;
}

.nav-item:hover, .nav-item.active {
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary-light);
}

.nav-item.active {
    border-right: 3px solid var(--primary);
}

.badge {
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: auto;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 16px 16px 16px 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    margin-bottom: 24px;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* Views */
.view-section {
    display: none;
    animation: fadeIn 0.4s ease;
}
.view-section.active {
    display: block;
}

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

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
}
.stat-card.primary::after { background: var(--primary); }
.stat-card.success::after { background: var(--success); }
.stat-card.warning::after { background: var(--warning); }
.stat-card.danger::after { background: var(--danger); }

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-card.primary .stat-icon { background: rgba(67, 97, 238, 0.15); color: var(--primary-light); }
.stat-card.success .stat-icon { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.stat-card.warning .stat-icon { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-card.danger .stat-icon { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.stat-details h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.stat-details p {
    font-size: 28px;
    font-weight: 700;
}

/* Table */
.table-container {
    padding: 24px;
}
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.search-box {
    position: relative;
    width: 300px;
}
.search-box i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-box input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: white;
    outline: none;
}
.search-box input:focus { border-color: var(--primary); }

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.data-table th, .data-table td {
    padding: 15px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
}

.data-table tbody tr {
    transition: background 0.2s;
}
.data-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}
.status-paid { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.status-soon { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-debt { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* Alerts */
.alerts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.alert-panel {
    padding: 24px;
}
.alert-panel h2 {
    font-size: 18px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-list {
    list-style: none;
}
.alert-list li {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.alert-list li:last-child { border-bottom: none; }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
}
.modal.show {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    width: 100%;
    max-width: 600px;
    padding: 24px;
    transform: translateY(-20px);
    transition: all 0.3s;
    margin: 20px;
}
.modal.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}
.close-btn:hover { color: white; }

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

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .dashboard-wrapper { flex-direction: column; }
    .sidebar { width: auto; height: auto; margin: 10px; flex-direction: row; flex-wrap: wrap; padding: 15px; }
    .sidebar-header { margin-bottom: 0; border-bottom: none; padding: 0; width: 100%; margin-bottom: 15px; justify-content: center;}
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; justify-content: center; width: 100%; gap: 5px;}
    .nav-item { padding: 8px 12px; font-size: 13px;}
    
    .main-content { padding: 10px; }
    .top-header { flex-direction: column; gap: 15px; align-items: flex-start; }
    
    .form-row { grid-template-columns: 1fr; }
    .alerts-grid { grid-template-columns: 1fr; }
    .search-box { width: 100%; }
}
