/* CRM Aura Labs — v2 */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-hover: rgba(255,255,255,0.05);
  --sidebar-width: 252px;
  --topbar-height: 52px;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --radius: 8px;
  --font-size: 15px;
  --font-size-sm: 13px;
  --font-size-lg: 17px;
  --font-size-xl: 26px;
  --transition: 0.18s ease;
}

[data-theme="dark"] {
  --bg: #0a0f1e;
  --surface: #111827;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #1f2937;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.4);
  --sidebar-bg: #060c18;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--font-size);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.screen { display: none; }
.screen.active { display: flex; }
.hidden { display: none !important; }
.error { color: var(--danger); margin-top: 0.5rem; font-size: var(--font-size-sm); }

/* ── Login ── */
#login {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #060c18 0%, #0f172a 55%, #1e3a8a 100%);
}
.login-box {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: 16px;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 24px 48px rgba(0,0,0,0.4);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.login-brand h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.login-box .subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: var(--font-size-sm);
}
.password-wrapper { position: relative; margin-bottom: 1rem; }
.login-box input {
  width: 100%;
  padding: 11px 44px 11px 14px;
  margin-bottom: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--font-size);
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
}
.login-box input:focus { outline: none; border-color: var(--primary); }
.login-box .toggle-password {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; color: var(--text-secondary); border: none; cursor: pointer;
  width: 32px; height: 32px; padding: 4px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.login-box .toggle-password:hover { color: var(--text); }
.login-box #loginBtn {
  width: 100%; padding: 12px; font-size: var(--font-size-lg);
  background: var(--primary); color: white; border: none;
  border-radius: var(--radius); cursor: pointer; font-weight: 600;
  transition: background var(--transition);
}
.login-box #loginBtn:hover { background: var(--primary-hover); }

/* ── Dashboard Layout ── */
#dashboard { display: flex; min-height: 100vh; }

/* ── Mobile Topbar ── */
#mobileTopbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--sidebar-bg);
  color: white;
  align-items: center;
  padding: 0 12px 0 8px;
  gap: 8px;
  z-index: 500;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
#mobileTopbar.topbar-hidden { display: none !important; }
.topbar-menu {
  background: none; border: none; color: white; cursor: pointer;
  padding: 8px; border-radius: 6px; display: flex; align-items: center;
  flex-shrink: 0;
}
.topbar-menu:hover { background: rgba(255,255,255,0.08); }
.topbar-title {
  font-weight: 700; font-size: 13px; letter-spacing: 1.5px;
  flex: 1; display: flex; align-items: center; gap: 8px;
}
.topbar-logout {
  background: none; border: none; color: #94a3b8; cursor: pointer;
  padding: 8px; border-radius: 6px; display: flex; align-items: center;
  flex-shrink: 0;
}
.topbar-logout:hover { color: #fca5a5; background: rgba(220,38,38,0.1); }

/* ── Sidebar Overlay (mobile) ── */
#sidebarOverlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 600;
  backdrop-filter: blur(2px);
}
#sidebarOverlay.active { display: block; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
  transition: width var(--transition);
}
#sidebar.collapsed { width: 58px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 16px;
  height: 60px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  min-width: 0;
}
.brand-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: white;
  white-space: nowrap;
}
.sidebar-collapse-btn {
  background: none; border: none; cursor: pointer;
  color: var(--sidebar-text); padding: 6px; border-radius: 6px;
  display: flex; align-items: center; flex-shrink: 0;
  transition: all var(--transition);
}
.sidebar-collapse-btn:hover { background: var(--sidebar-hover); color: white; }
#sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-parent {
  width: 100%; background: none; border: none;
  color: var(--sidebar-text);
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px 9px 16px;
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.sidebar-parent:hover { background: var(--sidebar-hover); color: white; }
.sidebar-parent:hover .nav-icon { opacity: 1; }
.nav-icon { flex-shrink: 0; opacity: 0.6; }
.nav-label { flex: 1; text-align: left; }

.arrow-icon {
  flex-shrink: 0;
  opacity: 0.5;
  transition: transform var(--transition);
  transform: rotate(-90deg);
}
.sidebar-parent.open .arrow-icon { transform: rotate(0deg); }

.badge {
  background: var(--danger); color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
  min-width: 18px; text-align: center; flex-shrink: 0;
}
.badge-red { background: var(--danger); }

.sidebar-children {
  overflow: hidden;
  max-height: 400px;
  transition: max-height 0.22s ease;
}
.sidebar-children.collapsed { max-height: 0; }
.sidebar-children a {
  display: block;
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 7px 14px 7px 41px;
  font-size: 13px;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
.sidebar-children a:hover { color: white; background: var(--sidebar-hover); }

/* Sidebar collapsed state */
#sidebar.collapsed .nav-label,
#sidebar.collapsed .brand-name,
#sidebar.collapsed .badge,
#sidebar.collapsed .arrow-icon,
#sidebar.collapsed .sidebar-children { display: none; }
#sidebar.collapsed .sidebar-parent {
  justify-content: center;
  padding: 10px;
}
#sidebar.collapsed .nav-icon { opacity: 0.7; }
#sidebar.collapsed .sidebar-header { padding: 0 6px; justify-content: center; gap: 6px; }
#sidebar.collapsed .sidebar-brand { min-width: 0; }
#sidebar.collapsed .sidebar-collapse-btn { display: flex; }

/* Footer: siempre visible */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 6px 0;
  flex-shrink: 0;
}
.sidebar-footer-btn {
  width: 100%; background: none; border: none;
  color: var(--sidebar-text);
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px 9px 16px;
  font-size: 13.5px; cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.sidebar-footer-btn:hover { background: var(--sidebar-hover); color: white; }
.logout-btn:hover { color: #fca5a5 !important; background: rgba(220,38,38,0.12) !important; }
#sidebar.collapsed .sidebar-footer-btn { justify-content: center; padding: 10px; }
#sidebar.collapsed .sidebar-footer-btn .nav-label { display: none; }

/* ── Main Content ── */
#mainContent {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: var(--bg);
}
.view { display: none; padding: 24px; }
.view.active { display: block; }
.view-header { margin-bottom: 20px; }
.view-header h2 { font-size: 20px; font-weight: 700; color: var(--text); }

/* ── Kanban ── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: start;
}
.kanban-col {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--card-shadow);
}
.kanban-col h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.col-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-lead { background: #94a3b8; }
.dot-calificado { background: #3b82f6; }
.dot-propuesta { background: #f59e0b; }
.dot-cliente { background: #16a34a; }

.kanban-cards { min-height: 48px; }
.kanban-card {
  background: var(--bg);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  border-left: 3px solid #94a3b8;
  transition: box-shadow var(--transition), transform var(--transition);
  font-size: 13.5px;
  box-shadow: var(--card-shadow);
}
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }
.kanban-card.recent { border-left-color: var(--success); }
.kanban-card.warning { border-left-color: var(--warning); }
.kanban-card.danger { border-left-color: var(--danger); }
.kanban-card .card-name { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.kanban-card .card-empresa { color: var(--text-secondary); font-size: 12px; }
.kanban-card .card-valor { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; justify-content: center; align-items: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-content {
  background: var(--surface);
  border-radius: 12px;
  padding: 2rem;
  max-width: 560px; width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary);
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* ── Buttons ── */
.btn {
  padding: 9px 18px; border-radius: var(--radius); border: none;
  font-size: var(--font-size); cursor: pointer; font-weight: 600;
  transition: background var(--transition);
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-weight: 600; font-size: var(--font-size-sm);
  margin-bottom: 5px; color: var(--text-secondary);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--font-size);
  background: var(--bg); color: var(--text);
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); }

/* ── Loading / Empty ── */
.loading, .empty { text-align: center; padding: 3rem; color: var(--text-secondary); }

/* ── Banner ── */
.system-banner {
  position: fixed; top: 0; left: 0; right: 0; padding: 11px;
  text-align: center; z-index: 2000;
  font-weight: 600; font-size: var(--font-size-sm);
}
.system-banner.info { background: var(--primary); color: white; }
.system-banner.error { background: var(--danger); color: white; }
.system-banner.success { background: var(--success); color: white; }

/* ── Responsive: tablet ── */
@media (max-width: 1100px) {
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
}

/* ── Responsive: móvil ── */
@media (max-width: 768px) {
  #mobileTopbar { display: flex; }

  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: 100%;
    z-index: 700;
    width: var(--sidebar-width) !important;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
  }
  #sidebar.mobile-open { transform: translateX(0); }

  #mainContent { margin-top: var(--topbar-height); }

  .view { padding: 16px; }

  .kanban-board {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .modal-content { padding: 1.5rem; }
  .modal { align-items: flex-end; padding: 0; }
  .modal-content {
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .login-box { padding: 2rem 1.5rem; }
}
