/* ═══════════════════════════════════════════════════════════════════════
   CRM Pro v8.0 — CSS principal
═══════════════════════════════════════════════════════════════════════ */

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

:root {
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --green-dark: #075E54;
    --green-mid: #128C7E;
    --green-light: #25D366;
    --primary: var(--green-mid);
    --danger: #dc2626;
    --warning: #f59e0b;
    --success: #10b981;
    --info: #3b82f6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.5;
}

/* ─── Layout ─────────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: linear-gradient(180deg, #075E54 0%, #128C7E 100%); color: white; flex-shrink: 0; overflow-y: auto; height: 100vh; position: sticky; top: 0; }
.sidebar-head { padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; gap: 10px; align-items: center; }
.logo-mini { font-size: 24px; }
.brand h2 { font-size: 17px; font-weight: 800; }
.brand small { font-size: 11px; opacity: 0.7; }
.sidebar-nav { padding: 12px 0; }
.nav-section { padding: 10px 18px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.6; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: white; text-decoration: none; font-size: 13px; cursor: pointer; transition: background 0.15s; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active { background: rgba(255,255,255,0.12); border-left-color: var(--green-light); font-weight: 700; }
.nav-item i { width: 16px; font-size: 13px; }

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: white; border-bottom: 1px solid var(--gray-200); position: sticky; top: 0; z-index: 100; }
.hamburger { display: none; background: transparent; border: none; font-size: 18px; cursor: pointer; padding: 8px; color: var(--gray-700); }
.topbar-spacer { flex: 1; }
.topbar-btn { background: transparent; border: 1px solid var(--gray-200); width: 38px; height: 38px; border-radius: 50%; cursor: pointer; position: relative; color: var(--gray-700); font-size: 14px; display: flex; align-items: center; justify-content: center; }
.topbar-btn:hover { background: var(--gray-100); }
.badge-count { position: absolute; top: -4px; right: -4px; background: var(--danger); color: white; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 10px; min-width: 18px; }
.user-dropdown { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid var(--gray-200); padding: 5px 12px 5px 5px; border-radius: 22px; cursor: pointer; }
.user-btn:hover { background: var(--gray-100); }
.user-avatar { background: linear-gradient(135deg, var(--green-mid), var(--green-light)); color: white; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.user-name { font-size: 12px; font-weight: 700; }
.user-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px; background: white; border: 1px solid var(--gray-200); border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,0.1); display: none; }
.user-dropdown.open .user-menu { display: block; }
.user-menu-info { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); }
.user-menu-info strong { display: block; font-size: 12px; color: var(--gray-800); }
.user-menu-info small { font-size: 11px; color: var(--gray-500); }
.user-menu-item { display: flex; gap: 10px; align-items: center; padding: 10px 14px; color: var(--gray-700); text-decoration: none; font-size: 13px; }
.user-menu-item:hover { background: var(--gray-50); }

.page-container { padding: 24px; flex: 1; }

/* ─── Components ────────────────────────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-title h1 { font-size: 22px; color: var(--gray-900); margin-bottom: 3px; }
.page-title p { font-size: 13px; color: var(--gray-500); }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; font-size: 13px; font-weight: 700; text-decoration: none; transition: all 0.15s; }
.btn-green { background: linear-gradient(135deg, var(--green-mid), var(--green-light)); color: white; }
.btn-green:hover { opacity: 0.92; }
.btn-outline { background: white; color: var(--gray-700); border-color: var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border: 1px solid var(--gray-200); background: white; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: var(--gray-100); }

.card { background: white; border: 1px solid var(--gray-200); border-radius: 12px; padding: 18px; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 5px; color: var(--gray-700); }
.form-input, .form-select, .form-textarea { width: 100%; padding: 9px 14px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 13px; box-sizing: border-box; background: white; color: var(--gray-800); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--green-light); box-shadow: 0 0 0 3px rgba(37,211,102,0.1); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert-success { background: #d1fae5; color: #065f46; border-left: 3px solid var(--success); }
.alert-error   { background: #fee2e2; color: #991b1b; border-left: 3px solid var(--danger); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 3px solid var(--warning); }
.alert-info    { background: #dbeafe; color: #1e40af; border-left: 3px solid var(--info); }

.badge { display: inline-block; padding: 3px 10px; font-size: 11px; font-weight: 700; border-radius: 12px; }
.badge-success { background: #d1fae5; color: #059669; }
.badge-warn    { background: #fed7aa; color: #9a3412; }
.badge-danger  { background: #fecaca; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

table.data-table { width: 100%; border-collapse: collapse; background: white; }
.data-table th { background: var(--gray-50); padding: 10px; text-align: left; font-size: 11px; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.3px; font-weight: 700; border-bottom: 1px solid var(--gray-200); }
.data-table td { padding: 12px 10px; font-size: 13px; border-bottom: 1px solid var(--gray-100); }
.data-table tr:hover { background: var(--gray-50); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi-card { background: white; padding: 16px; border: 1px solid var(--gray-200); border-radius: 12px; }
.kpi-label { font-size: 11px; text-transform: uppercase; color: var(--gray-500); font-weight: 700; }
.kpi-value { font-size: 22px; font-weight: 800; color: var(--gray-900); margin-top: 4px; }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; padding: 12px 18px; background: var(--gray-800); color: white; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.2); z-index: 9999; font-size: 13px; opacity: 0; transform: translateY(20px); transition: all 0.3s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,0.55); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: white; border-radius: 14px; max-width: 600px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-top { padding: 16px 20px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; }
.modal-top h3 { font-size: 16px; }
.modal-x { background: transparent; border: none; cursor: pointer; color: var(--gray-500); font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }

/* ─── Dark mode ──────────────────────────────────────────────────────── */
body.dark-mode { background: #0f172a; color: #e2e8f0; }
body.dark-mode .topbar { background: #1e293b; border-color: #334155; }
body.dark-mode .topbar-btn { background: #0f172a; border-color: #334155; color: #cbd5e1; }
body.dark-mode .card, body.dark-mode .modal-box, body.dark-mode .data-table, body.dark-mode .kpi-card { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark-mode .data-table th { background: #0f172a; color: #94a3b8; border-color: #334155; }
body.dark-mode .data-table td { border-color: #334155; }
body.dark-mode .data-table tr:hover { background: #0f172a; }
body.dark-mode .form-input, body.dark-mode .form-select, body.dark-mode .form-textarea { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.dark-mode .btn-outline { background: #1e293b; color: #cbd5e1; border-color: #334155; }
body.dark-mode .btn-icon { background: #1e293b; border-color: #334155; color: #cbd5e1; }
body.dark-mode .user-btn { background: #1e293b; border-color: #334155; }
body.dark-mode .user-menu { background: #1e293b; border-color: #334155; }
body.dark-mode .user-menu-item { color: #cbd5e1; }
body.dark-mode .user-menu-item:hover { background: #0f172a; }
body.dark-mode .page-title h1 { color: #f1f5f9; }
body.dark-mode .kpi-value { color: #f1f5f9; }

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar { position: fixed; left: -240px; transition: left 0.3s; z-index: 999; }
    .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.2); }
    .hamburger { display: flex; }
    .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .page-container { padding: 16px; }
    .page-title h1 { font-size: 18px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .user-name { display: none; }
}
