/* ═══════════════════════════════════════════════════════════
   ARIA DASHBOARD — Apple Minimalist & Futuristic Design System
   Sleek Glassmorphism · Premium Typography · Dual Theme System
   Designed for Acerotech
   ═══════════════════════════════════════════════════════════ */

/* ── DESIGN SYSTEM VARIABLES ──────────────────────────────── */
:root {
  /* Default Dark Theme (OLED / Space Gray) */
  --bg:            #000000;
  --bg-2:          #09090b;
  --bg-3:          #161618;
  --surface:       rgba(255, 255, 255, 0.04);
  --surface-2:     rgba(255, 255, 255, 0.08);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --border:        rgba(255, 255, 255, 0.065);
  --border-2:      rgba(255, 255, 255, 0.12);
  --text-1:        #ffffff;
  --text-2:        #a1a1a6;
  --text-3:        #86868b;
  
  /* Apple SF Color Palette (Dark) */
  --primary:       #0071e3;
  --primary-dim:   rgba(0, 113, 227, 0.15);
  --primary-hover: #0077ed;
  --primary-text:  #ffffff;
  
  --cyan:          #30b0c7;
  --indigo:        #5e5ce6;
  --green:         #30d158;
  --amber:         #ff9f0a;
  --red:           #ff453a;
  
  --sidebar-w:     220px;
  --topbar-h:      56px;
  --radius:        16px;
  --radius-sm:     10px;
  --radius-lg:     22px;
  
  --shadow-sm:     0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow:        0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg:     0 20px 50px rgba(0, 0, 0, 0.7);
  --glass-bg:      rgba(22, 22, 23, 0.65);
  
  --font-title:    'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-body:     'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono:     'JetBrains Mono', monospace;
}

/* Explicit Light Theme (Apple Studio / Clean Silver) */
:root[data-theme="light"] {
  --bg:            #f5f5f7;
  --bg-2:          #ffffff;
  --bg-3:          #ffffff;
  --surface:       rgba(0, 0, 0, 0.03);
  --surface-2:     rgba(0, 0, 0, 0.07);
  --surface-hover: rgba(0, 0, 0, 0.05);
  --border:        rgba(0, 0, 0, 0.06);
  --border-2:      rgba(0, 0, 0, 0.11);
  --text-1:        #1d1d1f;
  --text-2:        #6e6e73;
  --text-3:        #86868b;
  
  /* Apple SF Color Palette (Light) */
  --primary:       #0071e3;
  --primary-dim:   rgba(0, 113, 227, 0.08);
  --primary-hover: #0066cc;
  --primary-text:  #ffffff;
  
  --cyan:          #00a0b0;
  --indigo:        #5856d6;
  --green:         #34c759;
  --amber:         #ff9500;
  --red:           #ff3b30;
  
  --shadow-sm:     0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow:        0 8px 30px rgba(0, 0, 0, 0.06);
  --shadow-lg:     0 20px 50px rgba(0, 0, 0, 0.1);
  --glass-bg:      rgba(255, 255, 255, 0.7);
}

/* Explicit Dark Theme override */
:root[data-theme="dark"] {
  --bg:            #000000;
  --bg-2:          #09090b;
  --bg-3:          #161618;
  --surface:       rgba(255, 255, 255, 0.04);
  --surface-2:     rgba(255, 255, 255, 0.08);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --border:        rgba(255, 255, 255, 0.065);
  --border-2:      rgba(255, 255, 255, 0.12);
  --text-1:        #ffffff;
  --text-2:        #a1a1a6;
  --text-3:        #86868b;
  
  --primary:       #0071e3;
  --primary-dim:   rgba(0, 113, 227, 0.15);
  --primary-hover: #0077ed;
  --primary-text:  #ffffff;
  
  --cyan:          #30b0c7;
  --indigo:        #5e5ce6;
  --green:         #30d158;
  --amber:         #ff9f0a;
  --red:           #ff453a;
  
  --shadow-sm:     0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow:        0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg:     0 20px 50px rgba(0, 0, 0, 0.7);
  --glass-bg:      rgba(22, 22, 23, 0.65);
}

/* ── BASE RESET ────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* Smooth color transition for theme swaps */
  transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), 
              border-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), 
              color 0.25s cubic-bezier(0.16, 1, 0.3, 1), 
              box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.hidden { display: none !important; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ── SCROLLBARS ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ══════════════════════════════════════════════════════════════
   LOGIN SCREEN (Apple Glass Box)
   ══════════════════════════════════════════════════════════════ */
.login-bg {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
  z-index: 1000;
}

.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  opacity: 0.7;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  animation: orbFloat 10s ease-in-out infinite alternate;
}
.login-orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0, 113, 227, 0.15), transparent 75%);
  top: -150px; right: -100px;
}
.login-orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(94, 92, 230, 0.12), transparent 75%);
  bottom: -150px; left: -100px;
  animation-delay: -4s;
}

@keyframes orbFloat {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(40px, -30px) scale(1.08); }
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  padding: 3rem 2.5rem;
  background: var(--glass-bg);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.login-logo svg path {
  stroke: var(--primary);
  fill: var(--primary-dim);
}
.login-logo svg circle {
  fill: var(--primary);
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.03em;
}

.login-sub {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 0.5rem;
  margin-bottom: 2.25rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.login-form { text-align: left; }

.input-group { margin-bottom: 1.25rem; }

.input-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-2);
  margin-bottom: 0.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.input-field {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  color: var(--text-1);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.input-field:focus {
  border-color: var(--primary);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}
.input-field::placeholder { color: var(--text-3); }

.login-error {
  font-size: 0.75rem;
  color: var(--red);
  margin-bottom: 1rem;
  font-weight: 500;
}
.login-error.hidden { display: none; }

.login-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  border-radius: 9999px; /* Apple pill button */
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.login-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.02);
}
.login-btn:active {
  transform: scale(0.98);
}

.login-hint {
  font-size: 0.7rem;
  color: var(--text-3);
  margin-top: 2rem;
  letter-spacing: 0.02em;
}

/* ══════════════════════════════════════════════════════════════
   APP LAYOUT
   ══════════════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

/* Apple-style background grid */
.app-layout::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* Ambient glow */
.app-layout::after {
  content: '';
  position: fixed;
  top: -250px; right: -250px;
  width: 800px; height: 800px;
  background: radial-gradient(circle, rgba(0, 113, 227, 0.04), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── SIDEBAR (macOS Style) ────────────────────────────────── */
.sidebar {
  position: relative;
  z-index: 10;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-icon svg path {
  stroke: var(--primary);
  fill: var(--primary-dim);
}
.brand-icon svg circle {
  fill: var(--primary);
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand-sub {
  font-size: 0.65rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-section-label {
  font-size: 0.68rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 0.5rem 0.5rem 0.25rem 0.5rem;
  margin-top: 0.75rem;
}
.sidebar-nav > .nav-section-label:first-child {
  margin-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  position: relative;
}

.nav-item:hover {
  color: var(--text-1);
  background: var(--surface-hover);
}

.nav-item.active {
  color: var(--text-1);
  background: var(--surface-2);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: var(--primary);
  border-radius: 2px;
}

.nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: var(--text-3);
}
.nav-item.active .nav-icon {
  color: var(--primary);
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: var(--primary-text);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  line-height: 1;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--bg-2);
}

.conn-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-2);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9999px; /* Pill button */
  cursor: pointer;
  font-weight: 500;
}
.logout-btn:hover {
  color: var(--red);
  background: rgba(255, 69, 58, 0.08);
  border-color: rgba(255, 69, 58, 0.2);
}

/* ── STATUS DOTS ──────────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.status-dot--on  { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse-green 2s ease-in-out infinite; }
.status-dot--off { background: var(--red);   box-shadow: 0 0 6px var(--red); }
.status-dot--scan { background: var(--amber); box-shadow: 0 0 6px var(--amber); animation: pulse-amber 1.5s ease-in-out infinite; }

@keyframes pulse-green { 0%,100%{opacity:1} 50%{opacity:.5} }
@keyframes pulse-amber { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── TOPBAR ───────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

.page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
}

.topbar-right-container {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Theme Switcher Button Style */
.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--text-1);
  transform: scale(1.04);
}
.theme-toggle:active {
  transform: scale(0.96);
}
.theme-toggle svg {
  width: 16px;
  height: 16px;
}

/* Show/hide icons depending on theme */
:root[data-theme="light"] .sun-icon { display: none; }
:root[data-theme="light"] .moon-icon { display: block; }
:root[data-theme="dark"] .sun-icon { display: block; }
:root[data-theme="dark"] .moon-icon { display: none; }

/* Default to dark if no attribute set */
:root:not([data-theme="light"]) .sun-icon { display: block; }
:root:not([data-theme="light"]) .moon-icon { display: none; }

/* ── CONTENT AREA ─────────────────────────────────────────── */
.content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  padding: 1.75rem;
}

/* Chat sections (conversations/grupos) fill screen */
.section-chat {
  flex-direction: row;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.content-area:has(.section-chat:not(.hidden)) {
  padding: 0;
  overflow: hidden;
}

.section {
  animation: fadeUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

@keyframes shimmer {
  0%   { opacity: 0.3; }
  50%  { opacity: 0.7; }
  100% { opacity: 0.3; }
}

/* ══════════════════════════════════════════════════════════════
   COMPONENTS
   ══════════════════════════════════════════════════════════════ */

/* ── Apple Glass Card ─────────────────────────────────────── */
.card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card:hover {
  border-color: var(--border-2);
}
.card-glow:hover {
  box-shadow: var(--shadow);
}

/* ── KPI Card (Elegant Fitness-Style metrics) ─────────────── */
.kpi-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-color, var(--primary));
  opacity: 0.8;
}
.kpi-card:hover {
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
}

.kpi-value {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 0.35rem;
  font-family: var(--font-title);
}

.kpi-icon {
  position: absolute;
  top: 1.25rem; right: 1.25rem;
  font-size: 1.4rem;
  opacity: 0.75;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-2);
  font-weight: 500;
}

/* ── Buttons (Apple Style Pills) ──────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: 9999px; /* Pill */
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--font-title);
  line-height: 1;
  text-decoration: none;
}
.btn:hover {
  transform: scale(1.02);
}
.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.2);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(0, 113, 227, 0.3);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text-1);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-danger {
  background: rgba(255, 69, 58, 0.12);
  color: var(--red);
  border: 1px solid rgba(255, 69, 58, 0.2);
}
.btn-danger:hover {
  background: rgba(255, 69, 58, 0.2);
}

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.78rem; }

/* ── Form Inputs ──────────────────────────────────────────── */
.form-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.95rem;
  color: var(--text-1);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
}
.form-input:focus {
  border-color: var(--primary);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}
.form-input::placeholder { color: var(--text-3); }

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1rem;
  padding-right: 2.25rem;
}
select.form-input option { background: var(--bg-3); color: var(--text-1); }
textarea.form-input { resize: vertical; min-height: 80px; }

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 0.45rem;
  letter-spacing: -0.01em;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px; /* Pill */
}
.badge-nuevo       { background: rgba(0, 113, 227, 0.1);  color: var(--cyan); border: 1px solid rgba(0, 113, 227, 0.15); }
.badge-calificado  { background: rgba(48, 209, 88, 0.1);   color: var(--green); border: 1px solid rgba(48, 209, 88, 0.15); }
.badge-descartado  { background: rgba(255, 69, 58, 0.1);  color: var(--red); border: 1px solid rgba(255, 69, 58, 0.15); }
.badge-cerrado     { background: rgba(142, 142, 147, 0.1);  color: var(--text-2); border: 1px solid rgba(142, 142, 147, 0.15); }
.badge-pending     { background: rgba(255, 159, 10, 0.1);   color: var(--amber); border: 1px solid rgba(255, 159, 10, 0.15); }
.badge-sent        { background: rgba(0, 113, 227, 0.1);   color: var(--cyan); border: 1px solid rgba(0, 113, 227, 0.15); }
.badge-responded   { background: rgba(48, 209, 88, 0.1);   color: var(--green); border: 1px solid rgba(48, 209, 88, 0.15); }
.badge-connected   { background: rgba(48, 209, 88, 0.1);   color: var(--green); border: 1px solid rgba(48, 209, 88, 0.15); }
.badge-disconnected{ background: rgba(255, 69, 58, 0.1);  color: var(--red); border: 1px solid rgba(255, 69, 58, 0.15); }
.badge-scanning    { background: rgba(255, 159, 10, 0.1);   color: var(--amber); border: 1px solid rgba(255, 159, 10, 0.15); }

/* ── Agent chips ──────────────────────────────────────────── */
.agent-chip {
  display: inline-flex; align-items: center;
  font-size: 0.68rem; font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: 9999px;
  text-transform: capitalize;
}
.agent-ventas      { background: rgba(0, 113, 227, 0.1);  color: var(--cyan); }
.agent-operaciones { background: rgba(48, 209, 88, 0.1);  color: var(--green); }
.agent-rrhh        { background: rgba(94, 92, 230, 0.1); color: var(--indigo); }
.agent-proveeduria { background: rgba(255, 159, 10, 0.1);  color: var(--amber); }
.agent-mantenimiento { background: rgba(142, 142, 147, 0.1); color: var(--text-2); }

/* ── Table (Minimal Premium) ──────────────────────────────── */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  padding: 0.9rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.9rem 1.25rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover td { background: var(--surface); }
.data-table td.text-bright { color: var(--text-1); font-weight: 600; }

/* ── Filter Tabs ──────────────────────────────────────────── */
.filter-tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 2px;
}
.filter-tab {
  padding: 0.45rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.filter-tab:hover { color: var(--text-1); background: var(--surface-hover); }
.filter-tab.active {
  color: var(--text-1);
  background: var(--surface-2);
}
.filter-tab.active-blue {
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   CONVERSATIONS & MESSAGING (iMessage style)
   ══════════════════════════════════════════════════════════════ */
.chat-sidebar {
  width: 290px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-2);
  overflow: hidden;
}

.chat-search-wrap {
  position: relative;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.chat-search-icon {
  position: absolute;
  left: 1.6rem; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-3);
}
.chat-search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem 0.55rem 2.25rem;
  color: var(--text-1);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}
.chat-search:focus { border-color: var(--primary); background: var(--bg); }
.chat-search::placeholder { color: var(--text-3); }

.conv-list { flex: 1; overflow-y: auto; }

.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.conv-item:hover { background: var(--surface-hover); }
.conv-item.active { background: var(--primary-dim); }

.conv-avatar {
  width: 40px; height: 40px;
  border-radius: 50%; /* Apple rounded avatars */
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(94, 92, 230, 0.25), rgba(0, 113, 227, 0.25));
  color: var(--text-1);
  border: 1px solid var(--border);
}

.conv-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-preview {
  font-size: 0.8rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.conv-time {
  font-size: 0.72rem;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
}
.conv-meta { display: flex; align-items: center; gap: 0.4rem; margin-top: 5px; flex-wrap: wrap; }

/* Chat Main Panel */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  gap: 0.75rem;
}
.chat-empty p { font-size: 0.9rem; font-weight: 500; }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.chat-send {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}
.chat-send-row { display: flex; gap: 0.75rem; }

/* Chat Bubbles (iMessage Style) */
.bubble {
  max-width: 65%;
  padding: 0.7rem 1.1rem;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.45;
  word-break: break-word;
}
.bubble-user {
  background: var(--primary);
  color: var(--primary-text);
  border-bottom-right-radius: 4px;
  margin-left: auto;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.15);
}
.bubble-bot {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-bottom-left-radius: 4px;
}
.bubble-time {
  font-size: 0.68rem;
  color: var(--text-3);
  margin-top: 3px;
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════
   GRUPOS DE OBRA & OPS
   ══════════════════════════════════════════════════════════════ */
.group-auto-panel {
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--bg-2);
  overflow-y: auto;
}

.group-auto-panel:empty {
  display: none;
}

.group-section-header {
  padding: 1rem 1.25rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.reminder-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.5rem;
}
.reminder-item:hover { border-color: var(--border-2); }

.group-task-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.group-task-item:last-child { border-bottom: none; }

.msg-system {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0;
}
.msg-system-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.45rem 1.1rem;
  font-size: 0.78rem;
  color: var(--text-2);
  max-width: 80%;
  text-align: center;
  font-weight: 500;
}
.msg-task-bubble {
  background: rgba(48, 209, 88, 0.08);
  border: 1px solid rgba(48, 209, 88, 0.2);
  border-radius: 20px;
  padding: 0.45rem 1.1rem;
  font-size: 0.78rem;
  color: var(--green);
  max-width: 80%;
  text-align: center;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   WHATSAPP SECTION
   ══════════════════════════════════════════════════════════════ */
.wa-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  max-width: 500px;
  box-shadow: var(--shadow-sm);
}

.qr-frame {
  display: inline-flex;
  padding: 16px;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ══════════════════════════════════════════════════════════════
   CALENDAR
   ══════════════════════════════════════════════════════════════ */
.cal-day {
  min-height: 90px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
}
.cal-day:hover { background: var(--surface-hover); border-color: var(--border-2); }
.cal-day.today { border-color: var(--primary); box-shadow: 0 0 10px rgba(0, 113, 227, 0.15); }
.cal-day.other-month { opacity: 0.2; }

.cal-event-dot {
  font-size: 0.72rem;
  background: var(--primary-dim);
  color: var(--primary);
  border-radius: 5px;
  padding: 2px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none !important; }

.modal-box {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-body { overflow-y: auto; padding: 1.5rem; }

@keyframes slideModal {
  from { opacity: 0; transform: scale(0.97) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--text-1); }

.modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: none; background: var(--surface);
  border-radius: 50%; cursor: pointer; color: var(--text-2);
}
.modal-close:hover { background: var(--surface-2); color: var(--text-1); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.45rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: 1.25rem;
}

/* ══════════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 3000;
  padding: 0.85rem 1.35rem;
  border-radius: 9999px; /* Pill toast */
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 320px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.toast.hidden { display: none; }
.toast-success { background: rgba(48, 209, 88, 0.95); color: #ffffff; }
.toast-error   { background: rgba(255, 69, 58, 0.95); color: #ffffff; }
.toast-info    { background: rgba(0, 113, 227, 0.95); color: #ffffff; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ══════════════════════════════════════════════════════════════
   TEAM CARDS
   ══════════════════════════════════════════════════════════════ */
.team-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.team-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 113, 227, 0.03), transparent);
  opacity: 0;
  pointer-events: none;
}
.team-card:hover {
  border-color: var(--border-2);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.team-card:hover::after { opacity: 1; }

.team-avatar {
  width: 48px; height: 48px;
  border-radius: 50%; /* Rounded Apple-like */
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; font-weight: 700;
  background: linear-gradient(135deg, rgba(94, 92, 230, 0.15), rgba(0, 113, 227, 0.15));
  border: 1px solid var(--border);
  color: var(--text-1);
  margin-bottom: 1rem;
}

/* ══════════════════════════════════════════════════════════════
   MISCELLANEOUS HELPERS
   ══════════════════════════════════════════════════════════════ */
.mono { font-family: var(--font-mono); }
.text-bright { color: var(--text-1) !important; }
.text-muted { color: var(--text-3) !important; }
.text-primary { color: var(--primary); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.section-title { font-size: 0.95rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }

@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

/* Empty State Box */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4rem 2rem; color: var(--text-3); gap: 1rem; text-align: center;
}
.empty-state svg { opacity: 0.4; color: var(--text-3); }
.empty-state p { font-size: 0.9rem; font-weight: 500; }

/* Grid Helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
@media (max-width:1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width:900px)  { .grid-3 { grid-template-columns: repeat(2, 1fr); } }

/* ── Protocolo de Obra ─────────────────────────────────────────── */
.checkpoint-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1px solid var(--border); border-radius: 9999px;
  padding: 0.3rem 0.85rem; font-size: 0.8rem;
  background: var(--surface);
}
.checkpoint-status {
  font-weight: 600; margin-left: 0.25rem;
}
.date-chip {
  font-size: 0.8rem; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 0.35rem 0.85rem; border-radius: 9999px;
  font-weight: 500;
}
.alert-card {
  background: rgba(255, 159, 10, 0.08); border: 1px solid rgba(255, 159, 10, 0.2);
  border-radius: var(--radius-sm); padding: 1rem 1.25rem;
  font-size: 0.85rem; color: var(--amber);
  font-weight: 500;
}
.fw-600 { font-weight: 600; }
.badge--blue { background: var(--primary-dim); color: var(--primary); padding: 3px 8px; border-radius: 5px; font-weight: 600; font-size: 0.72rem; }
.badge--gray { background: var(--surface); color: var(--text-2); padding: 3px 8px; border-radius: 5px; font-weight: 500; font-size: 0.72rem; }


/* ══════════════════════════════════════════════════════════════
   VEHICLE DRAWER (Apple Slide Drawer)
   ══════════════════════════════════════════════════════════════ */
.vh-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.2s ease;
}

.vh-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(720px, 100vw);
  height: 100vh;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.vh-drawer-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
  flex-shrink: 0;
}

.vh-drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
  padding: 0 1.25rem;
  overflow-x: auto;
  flex-shrink: 0;
  gap: 1rem;
}
.vh-drawer-tabs::-webkit-scrollbar { height: 0; }

.vh-drawer-tab {
  padding: 1rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  user-select: none;
}
.vh-drawer-tab:hover { color: var(--text-2); }
.vh-drawer-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.vh-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.vh-tab-pane { animation: fadeIn 0.2s ease; }

.vh-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.vh-info-item {
  padding: 0.75rem 1rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.vh-info-item.full { grid-column: span 2; }

.vh-info-label {
  font-size: 0.68rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
  font-weight: 700;
}

.vh-info-value {
  font-size: 0.875rem;
  color: var(--text-1);
  font-weight: 600;
}

.vh-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.vh-log-entry {
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--border-2);
  margin-bottom: 0.75rem;
  background: var(--bg-3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border: 1px solid var(--border);
  border-left-width: 3px;
}
.vh-log-entry.correctivo { border-left-color: var(--red); }
.vh-log-entry.preventivo { border-left-color: var(--green); }
.vh-log-entry.revision   { border-left-color: var(--amber); }

.vh-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.vh-photo-item {
  aspect-ratio: 4/3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  background: var(--surface);
}
.vh-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.vh-photo-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.75);
  border: none;
  color: white;
  cursor: pointer;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}
.vh-photo-item:hover .vh-photo-remove { opacity: 1; }

.vh-warn-banner {
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════
   CHECKLIST OPERACIONAL
   ══════════════════════════════════════════════════════════════ */
.checklist-filter-btn {
  padding: 0.55rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 9999px; /* Pill */
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}
.checklist-filter-btn:hover {
  background: var(--surface-hover);
  color: var(--text-1);
}
.checklist-filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.checklist-view {
  transition: opacity 0.2s;
}
.checklist-view.hidden {
  display: none !important;
}

.checklist-responsible-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.checklist-responsible-card:hover {
  border-left-color: var(--primary-hover);
  box-shadow: var(--shadow);
}

.checklist-progress {
  background: var(--surface);
  height: 8px;
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 0.75rem;
}

.checklist-progress-bar {
  background: linear-gradient(90deg, var(--green), var(--cyan));
  height: 100%;
  width: 0%;
  border-radius: 9999px;
}

.checklist-activity-log {
  margin-top: 2rem;
  padding: 1.25rem;
  background: rgba(48, 209, 88, 0.06);
  border-radius: var(--radius);
  border-left: 4px solid var(--green);
}

.checklist-activity-item {
  padding: 0.65rem 0;
  font-size: 0.85rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.checklist-activity-item:last-child {
  border-bottom: none;
}
.checklist-activity-item strong {
  color: var(--text-1);
}
.checklist-activity-item .time {
  color: var(--green);
  font-weight: 600;
  margin-right: 0.5rem;
}
