:root {
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 250px;
    --header-height: 60px;
    --ad-footer-height: 90px;
    --danger-color: #ef4444;
    --success-color: #10b981;
}

[data-theme="dark"] {
    --bg-color: #111827;
    --surface-color: #1f2937;
    --text-color: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: #374151;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg-color); color: var(--text-color); }
a { text-decoration: none; color: var(--primary-color); }

/* Layout App */
.app-body { overflow: hidden; height: 100vh; }
.app-container { display: flex; height: 100vh; }
.sidebar { width: var(--sidebar-width); background: var(--surface-color); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; transition: margin-left 0.3s ease, transform 0.3s ease; margin-left: calc(var(--sidebar-width) * -1); z-index: 1000; }
.sidebar.active { margin-left: 0; }
.sidebar-header { height: var(--header-height); display: flex; align-items: center; padding: 0 1.5rem; border-bottom: 1px solid var(--border-color); }
.sidebar-nav ul { list-style: none; padding: 1rem 0; }
.sidebar-nav a { display: block; padding: 0.75rem 1.5rem; color: var(--text-color); }
.sidebar-nav a:hover { background: var(--bg-color); }

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; width: 100%; }
.app-header { height: var(--header-height); background: var(--surface-color); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; padding: 0 1.5rem; }
.header-left, .header-right { display: flex; align-items: center; gap: 1rem; }
.content-wrapper { flex: 1; overflow-y: auto; padding: 1.5rem; }

/* Layout Public */
.public-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--surface-color); padding: 2rem; border-radius: 0.5rem; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); width: 100%; max-width: 400px; }
.login-logo { text-align: center; margin-bottom: 2rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select, .form-control { width: 100%; padding: 0.5rem; border: 1px solid var(--border-color); border-radius: 0.25rem; background: var(--bg-color); color: var(--text-color); font-family: inherit; }

/* Components */
.btn { display: inline-block; padding: 0.5rem 1rem; border-radius: 0.25rem; border: none; cursor: pointer; font-weight: 500; text-align: center; }
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-color); }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; }
.btn-icon { background: transparent; border: none; cursor: pointer; font-size: 1.25rem; color: var(--text-color); }

.card { background: var(--surface-color); border-radius: 0.5rem; border: 1px solid var(--border-color); margin-bottom: 1rem; }
.card-body { padding: 1.5rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }

.alert { padding: 1rem; border-radius: 0.25rem; margin-bottom: 1rem; }
.alert-error { background: #fee2e2; color: var(--danger-color); border: 1px solid #f87171; }
.alert-success { background: #d1fae5; color: var(--success-color); border: 1px solid #34d399; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.breadcrumb ul { list-style: none; display: flex; gap: 0.5rem; color: var(--text-muted); }
.breadcrumb li:not(:last-child)::after { content: "/"; margin-left: 0.5rem; }

.ad-slot { width: 100%; background: var(--surface-color); display: flex; align-items: center; justify-content: center; border-top: 1px solid var(--border-color); }
.ad-slot-footer { height: var(--ad-footer-height); flex-shrink: 0; }
.ad-slot.dev-mode { background: #e5e7eb; color: #6b7280; font-size: 0.875rem; border: 1px dashed #9ca3af; }

.divider { text-align: center; margin: 1rem 0; color: var(--text-muted); position: relative; }
.divider::before, .divider::after { content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border-color); }
.divider::before { left: 0; }
.divider::after { right: 0; }

/* Auth Styles */
.password-input-wrapper { position: relative; display: flex; align-items: center; }
.password-input-wrapper input { padding-right: 40px; }
.password-input-wrapper .toggle-password { position: absolute; right: 10px; background: none; border: none; cursor: pointer; font-size: 1.2rem; }
.error-text { color: var(--danger-color); font-size: 0.875rem; margin-top: 0.25rem; display: block; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.bg-gray-100 { background-color: #f3f4f6 !important; color: #6b7280; cursor: not-allowed; }
.alert-info { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

/* Mobile */
@media (max-width: 768px) {
    .sidebar { position: fixed; height: 100%; margin-left: 0; transform: translateX(-100%); }
    .sidebar.active { transform: translateX(0); margin-left: 0; }
}

/* Dashboard Styles */
.dashboard-content { display: flex; flex-direction: column; gap: 1.5rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.kpi-card { background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 8px; padding: 1.25rem; display: flex; align-items: center; gap: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.kpi-icon { font-size: 2rem; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--bg-color); }
.kpi-content { flex: 1; }
.kpi-title { margin: 0; font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }
.kpi-value { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--text-color); }

.kpi-primary .kpi-icon { background: #e0e7ff; color: #4f46e5; }
.kpi-success .kpi-icon { background: #dcfce7; color: #16a34a; }
.kpi-warning .kpi-icon { background: #fef9c3; color: #ca8a04; }
.kpi-danger .kpi-icon { background: #fee2e2; color: #dc2626; }

.dashboard-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 1.5rem; }
.panel { background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.panel-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: #f9fafb; }
.panel-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.panel-body { padding: 1.25rem; }

.list-group { display: flex; flex-direction: column; gap: 0.75rem; }
.list-item { display: flex; justify-content: space-between; align-items: center; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border-color); }
.list-item:last-child { border-bottom: none; padding-bottom: 0; }
.list-item-content h4 { margin: 0 0 0.25rem 0; font-size: 0.95rem; display: flex; align-items: center; gap: 0.5rem; }
.list-item-content p { margin: 0; }
.badge { display: inline-block; padding: 0.15rem 0.5rem; font-size: 0.75rem; font-weight: 600; border-radius: 9999px; background: #e5e7eb; color: #374151; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-success { background: #dcfce7; color: #166534; }
.text-sm { font-size: 0.875rem; }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.875rem; }

/* Profile & Matrix Styles */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
.table th { background: #f9fafb; font-weight: 600; color: var(--text-muted); font-size: 0.875rem; }
.p-0 { padding: 0 !important; }
.text-right { text-align: right; }
.ml-2 { margin-left: 0.5rem; }
.row { display: flex; flex-wrap: wrap; margin: 0 -1rem; }
.col-md-4 { flex: 0 0 33.333333%; padding: 0 1rem; }
.col-md-8 { flex: 0 0 66.666667%; padding: 0 1rem; }

.permission-group-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--primary-color); color: var(--primary-color); }
.permission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.permission-item { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: 6px; cursor: pointer; transition: all 0.2s; }
.permission-item:hover { border-color: var(--primary-color); background: #f8fafc; }
.permission-item input[type="checkbox"] { margin-top: 0.25rem; width: 18px; height: 18px; }
.permission-info { display: flex; flex-direction: column; flex: 1; }
.permission-name { font-weight: 600; font-size: 0.9rem; }
.permission-slug { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); }
.permission-item.disabled { background: #f3f4f6; cursor: not-allowed; opacity: 0.8; }
.panel-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border-color); background: #f9fafb; }

@media (max-width: 992px) {
    .col-md-4, .col-md-8 { flex: 0 0 100%; }
}

/* User Module Styles */
.filter-form .row { align-items: flex-end; }
.text-xs { font-size: 0.75rem; }
.text-success { color: #16a34a; }
.text-warning { color: #ca8a04; }
.ml-1 { margin-left: 0.25rem; }
.justify-center { justify-content: center; }
.col-md-6 { flex: 0 0 50%; padding: 0 1rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 500; }
.checkbox-label input { width: 18px; height: 18px; }
.my-4 { margin-top: 1rem; margin-bottom: 1rem; }
.pagination { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-color); }
.pagination-links { display: flex; gap: 0.5rem; }
.btn-link { background: none; border: none; padding: 0; color: var(--primary-color); cursor: pointer; text-decoration: underline; font-family: inherit; }
.btn-link:hover { color: var(--primary-hover); }

@media (max-width: 768px) {
    .col-md-6 { flex: 0 0 100%; }
}
