/* ═══ ImobCRM — style.css v5 ═══════════════════════════════════════════════ */

:root {
    --bg: #f8fafc; --bg2: #ffffff; --bg3: #f1f5f9;
    --text: #1e293b; --text2: #64748b;
    --border: #e2e8f0;
    --primary: #3b82f6; --primary-hover: #2563eb; --primary-light: rgba(59,130,246,0.08);
    --success: #22c55e; --warning: #f59e0b; --danger: #ef4444;
    --purple: #8b5cf6; --indigo: #6366f1; --orange: #f97316;
    --radius: 12px; --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}
[data-theme="dark"] {
    --bg: #0f172a; --bg2: #1e293b; --bg3: #334155;
    --text: #f1f5f9; --text2: #94a3b8;
    --border: #334155;
    --primary-light: rgba(59,130,246,0.15);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; flex-direction: column; font-size: 15px; }

/* ═══ TOPBAR ═══ */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: var(--bg2); border-bottom: 1px solid var(--border); box-shadow: 0 1px 8px rgba(0,0,0,0.06); backdrop-filter: blur(12px); }
[data-theme="dark"] .topbar { background: rgba(30,41,59,0.95); box-shadow: 0 1px 12px rgba(0,0,0,0.3); }

/* Row 1: brand + search + user */
.topbar-row1 { display: flex; align-items: center; justify-content: space-between; height: 50px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.topbar-brand { display: flex; align-items: center; gap: 6px; text-decoration: none; font-size: 1.1rem; font-weight: 700; color: var(--primary); white-space: nowrap; }
.topbar-brand span { background: linear-gradient(135deg, var(--primary), var(--purple)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Row 2: navigation */
.topbar-row2 { display: flex; align-items: center; height: 42px; position: relative; }
.topbar-nav { display: flex; align-items: center; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; padding: 0 36px; scroll-behavior: smooth; }
.topbar-nav::-webkit-scrollbar { display: none; }

/* Scroll arrows */
.nav-arrow { position: absolute; top: 0; bottom: 0; width: 32px; z-index: 2; border: none; background: linear-gradient(90deg, var(--bg2) 60%, transparent); color: var(--text2); font-size: 1.4rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: opacity 0.2s, color 0.15s; }
.nav-arrow:hover { color: var(--primary); }
.nav-arrow-left { left: 0; }
.nav-arrow-right { right: 0; background: linear-gradient(-90deg, var(--bg2) 60%, transparent); }
[data-theme="dark"] .nav-arrow-left { background: linear-gradient(90deg, var(--bg2) 60%, transparent); }
[data-theme="dark"] .nav-arrow-right { background: linear-gradient(-90deg, var(--bg2) 60%, transparent); }
.nav-arrow.hidden { opacity: 0; pointer-events: none; }

/* Nav links */
.topbar-link { display: flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 8px; font-size: 0.78rem; font-weight: 500; color: var(--text2); text-decoration: none; white-space: nowrap; transition: all 0.2s ease; position: relative; }
.topbar-link svg { width: 15px; height: 15px; flex-shrink: 0; }
.topbar-link:hover { color: var(--primary); background: var(--primary-light); transform: translateY(-1px); }
.topbar-link.active { color: #fff; background: linear-gradient(135deg, var(--primary), var(--indigo)); box-shadow: 0 2px 8px rgba(59,130,246,0.35); }
.topbar-link.active:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(59,130,246,0.45); }
.nav-badge { background: var(--danger); color: #fff; font-size: 0.55rem; font-weight: 700; padding: 1px 5px; border-radius: 10px; margin-left: 2px; line-height: 1.4; }

/* Right section */
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.topbar-search { position: relative; }
.topbar-search input { width: 180px; padding: 7px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; color: var(--text); font-size: 0.8rem; transition: all 0.25s; }
.topbar-search input:focus { outline: none; border-color: var(--primary); width: 280px; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.topbar-search .search-results { display: none; position: absolute; top: calc(100% + 6px); right: 0; width: 340px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto; z-index: 300; }
.topbar-icon-btn { background: none; border: 1px solid var(--border); border-radius: 50%; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 0.95rem; color: var(--text2); transition: all 0.2s; }
.topbar-icon-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); transform: scale(1.08); }

/* User dropdown */
.topbar-user { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 8px; border-radius: 20px; transition: background 0.2s; position: relative; }
.topbar-user:hover { background: var(--bg3); }
.topbar-avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--purple)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.75rem; flex-shrink: 0; }
.topbar-username { font-size: 0.82rem; font-weight: 500; color: var(--text); max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user svg { color: var(--text2); flex-shrink: 0; }
.topbar-dropdown { display: none; position: absolute; top: calc(100% + 8px); right: 0; min-width: 200px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden; z-index: 500; }
.topbar-dropdown.open { display: block; animation: dropIn 0.15s ease; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.topbar-dropdown-info { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.topbar-dropdown-info strong { display: block; font-size: 0.88rem; color: var(--text); }
.topbar-dropdown-info span { font-size: 0.72rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
.topbar-dropdown a { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 0.85rem; color: var(--text2); text-decoration: none; transition: all 0.15s; }
.topbar-dropdown a:hover { background: var(--primary-light); color: var(--primary); }

/* Hamburger for mobile */
.topbar-hamburger { display: none; }

/* ═══ MAIN ═══ */
.main { margin-top: 92px; flex: 1; padding: 28px 32px; min-height: calc(100vh - 92px); display: flex; flex-direction: column; min-width: 0; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.page-header p { color: var(--text2); font-size: 0.88rem; margin-top: 2px; }

/* ═══ STATS / KPI CARDS ═══ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stats-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stats-grid.cols-7 { grid-template-columns: repeat(7, 1fr); }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden; transition: box-shadow 0.2s, border-color 0.2s; }
.stat-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.stat-card .stat-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 10px; }
.stat-card .label { font-size: 0.75rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.6px; }
.stat-card .value { font-size: 1.7rem; font-weight: 700; margin: 4px 0 2px; }
.stat-card .sub { font-size: 0.75rem; color: var(--text2); }
.stat-card .trend { font-size: 0.72rem; font-weight: 600; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* ═══ CARDS ═══ */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }

/* ═══ TABLES ═══ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 14px; text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text2); background: var(--bg3); border-bottom: 1px solid var(--border); white-space: nowrap; font-weight: 600; }
td { padding: 12px 14px; font-size: 0.88rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--primary-light); }

/* ═══ BADGES ═══ */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }

/* ═══ AVATAR ═══ */
.avatar { width: 36px; height: 36px; border-radius: 10px; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.72rem; flex-shrink: 0; letter-spacing: 0.3px; }

/* ═══ BUTTONS ═══ */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: all 0.15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: rgba(239,68,68,0.12); color: var(--danger); border: 1px solid rgba(239,68,68,0.25); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text2); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: var(--radius-sm); border: 1px solid var(--border); background: transparent; color: var(--text2); cursor: pointer; transition: all 0.15s; }
.btn-icon:hover { background: var(--bg3); color: var(--text); }

/* ═══ FORMS ═══ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 0.82rem; color: var(--text2); font-weight: 500; }
input, select, textarea { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px; font-size: 0.88rem; font-family: inherit; transition: border-color 0.15s; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--bg2); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; grid-column: 1 / -1; }

/* ═══ FILTERS ═══ */
.filters { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters input, .filters select { min-width: 160px; flex: 1; max-width: 260px; }

/* ═══ ALERTS ═══ */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.88rem; margin-bottom: 16px; }
.alert-success { background: rgba(34,197,94,0.1); color: var(--success); border: 1px solid rgba(34,197,94,0.25); }
.alert-error { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.25); }
.alert-warning { background: rgba(245,158,11,0.1); color: var(--warning); border: 1px solid rgba(245,158,11,0.25); }

/* ═══ MODAL ═══ */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; overflow-y: auto; padding: 40px 20px; }
.modal-overlay.active { display: flex; align-items: flex-start; justify-content: center; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); max-width: 640px; width: 100%; padding: 24px; box-shadow: var(--shadow-md); }
.modal-sm { max-width: 420px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-head h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text2); font-size: 1rem; cursor: pointer; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { color: var(--text); border-color: var(--text2); }

/* ═══ PAGINATION ═══ */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 20px; }
.page-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500; color: var(--text2); background: var(--bg2); border: 1px solid var(--border); text-decoration: none; transition: all 0.15s; cursor: pointer; }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ═══ ROW ACTIONS MENU ═══ */
.row-actions { position: relative; }
.row-actions-trigger { background: none; border: 1px solid transparent; border-radius: var(--radius-sm); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text2); transition: all 0.15s; }
.row-actions-trigger:hover, .row-actions.open .row-actions-trigger { background: var(--bg3); border-color: var(--border); color: var(--text); }
.row-actions-menu { display: none; position: absolute; right: 0; top: calc(100% + 4px); min-width: 180px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 50; overflow: hidden; }
.row-actions.open .row-actions-menu { display: block; animation: dropIn 0.15s ease; }
.row-actions-menu a { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-size: 0.82rem; color: var(--text2); text-decoration: none; transition: all 0.15s; }
.row-actions-menu a:hover { background: var(--primary-light); color: var(--primary); }
.row-actions-menu a.row-actions-danger { color: var(--danger); }
.row-actions-menu a.row-actions-danger:hover { background: rgba(239,68,68,0.08); }
.row-actions-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ═══ BULK ACTION BAR ═══ */
.bulk-bar { position: fixed; bottom: -60px; left: 50%; transform: translateX(-50%); background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 20px; display: flex; align-items: center; gap: 12px; box-shadow: 0 -2px 20px rgba(0,0,0,0.12); z-index: 90; font-size: 0.85rem; font-weight: 500; color: var(--text); transition: bottom 0.3s cubic-bezier(.4,0,.2,1); }
.bulk-bar.visible { bottom: 24px; }
[data-theme="dark"] .bulk-bar { box-shadow: 0 -2px 24px rgba(0,0,0,0.4); }

/* ═══ EMPTY STATE ═══ */
.empty { text-align: center; padding: 48px 20px; color: var(--text2); }
.empty svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.3; }

/* ═══ PIPELINE BAR ═══ */
.pipeline-bar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--bg3); }
.pipeline-bar .segment { height: 100%; transition: width 0.4s; }

/* ═══ CHARTS ═══ */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.chart-wrap { padding: 20px; }

/* ═══ DETAIL GRID ═══ */
.detail-grid { display: grid; grid-template-columns: 1fr 360px; gap: 20px; }
.info-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; flex-wrap: wrap; gap: 4px; }
.info-row:last-child { border-bottom: none; }
.info-row .key { color: var(--text2); }
.info-row .val { font-weight: 500; }

/* ═══ TABS ═══ */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab { padding: 10px 18px; font-size: 0.88rem; font-weight: 500; color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; background: none; border-top: none; border-left: none; border-right: none; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ═══ LOGIN ═══ */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100%; background: var(--bg); padding: 20px; }
.login-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.login-box h1 { color: var(--primary); font-size: 1.4rem; margin-bottom: 4px; }
.login-box p { color: var(--text2); font-size: 0.85rem; margin-bottom: 24px; }
.login-box .form-group { margin-bottom: 14px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 6px; padding: 12px; }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .stats-grid.cols-7 { grid-template-columns: repeat(4, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .topbar-row1 { padding: 0 12px; }
    .topbar-search input { width: 120px; }
    .topbar-search input:focus { width: 180px; }
    .topbar-username { display: none; }
    .topbar-link span { display: none; }
    .topbar-link { padding: 6px 10px; }
    .topbar-link svg { width: 18px; height: 18px; }
}
@media (max-width: 768px) {
    .main { padding: 20px 16px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header h2 { font-size: 1.25rem; }
    .stats-grid, .stats-grid.cols-3, .stats-grid.cols-7 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .value { font-size: 1.3rem; }
    .form-grid { grid-template-columns: 1fr; }
    .filters { flex-direction: column; align-items: stretch; }
    .filters input, .filters select { width: 100%; max-width: none; min-width: 0; }
    .detail-grid { grid-template-columns: 1fr; }
    .modal { margin: 10px; max-width: 95vw; }
}
@media (max-width: 480px) {
    .stats-grid, .stats-grid.cols-3, .stats-grid.cols-7 { grid-template-columns: 1fr 1fr; }
    .stat-card .value { font-size: 1.15rem; }
    .btn { padding: 8px 14px; font-size: 0.82rem; }
    .btn-sm { padding: 5px 10px; font-size: 0.78rem; }
}
