/* ==================== IDEI-A Sales Tracker - Refined Minimal Theme ==================== */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --bg-main: #fafafa;
  --bg-white: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f4f4f5;
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  --border-color: #e4e4e7;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==================== Login Screen ==================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #ffffff;
}

.login-logo {
  margin-bottom: 2.5rem;
}

.login-logo img {
  height: 48px;
  width: auto;
  display: block;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
  letter-spacing: -0.025em;
}

.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-size: 0.9375rem;
  font-weight: 400;
}

.login-form {
  width: 100%;
  max-width: 320px;
}

.login-error {
  color: var(--danger);
  text-align: center;
  margin-top: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

/* ==================== Form Elements ==================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  background: var(--bg-white);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

/* ==================== Buttons ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  border-radius: 8px;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.25rem;
  padding: 0.5rem;
  cursor: pointer;
}

/* ==================== Header ==================== */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--bg-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 1rem;
  padding-right: 1rem;
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
}

.header-logo {
  height: 24px;
  width: auto;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

/* ==================== Bottom Navigation ==================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-white);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  border-top: 1px solid var(--border-color);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.75rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  min-width: 56px;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 1.375rem;
}

.nav-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* ==================== Page Content ==================== */
.page-content {
  padding: calc(64px + var(--safe-top)) 1rem calc(72px + var(--safe-bottom)) 1rem;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  flex: 1;
  font-size: 1.25rem;
  font-weight: 700;
}

.section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 1.5rem 0 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ==================== Dashboard ==================== */
.dashboard-header {
  margin-bottom: 1.5rem;
}

.dashboard-header h2 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.stat-card {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid var(--border-color);
}

.stat-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.activity-summary {
  background: var(--bg-card);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.activity-row {
  display: flex;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.activity-row:last-child {
  border-bottom: none;
}

.activity-row span {
  color: var(--text-secondary);
}

.activity-row strong {
  color: var(--text-primary);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

.quick-btn:active {
  background: var(--bg-input);
}

.quick-icon {
  font-size: 1.5rem;
}

.quick-btn span:last-child {
  font-size: 0.8125rem;
  font-weight: 600;
}

/* ==================== Cards ==================== */
.prospecto-card, .venta-card, .sala-card {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 14px;
  margin-bottom: 0.625rem;
  border: 1px solid var(--border-color);
}

.prospecto-header, .venta-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.375rem;
}

.prospecto-contacto, .venta-cliente {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.prospecto-status, .venta-fecha, .sala-codigo {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.sala-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sala-info { flex: 1; }

.sala-nombre {
  font-weight: 600;
}

.sala-tipo {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sala-actions {
  display: flex;
  gap: 0.5rem;
}

/* ==================== Badges ==================== */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-frio { background: #dbeafe; color: #1d4ed8; }
.badge-tibio { background: #fef3c7; color: #b45309; }
.badge-caliente { background: #fee2e2; color: #dc2626; }

/* ==================== Total/Comision Card ==================== */
.total-card {
  background: var(--primary);
  padding: 1.25rem;
  border-radius: 14px;
  text-align: center;
  margin-bottom: 1rem;
  color: white;
}

.total-label { font-size: 0.8125rem; opacity: 0.85; }
.total-value { font-size: 2rem; font-weight: 700; margin-top: 0.25rem; }

.comision-card {
  background: var(--success);
  padding: 1.25rem;
  border-radius: 14px;
  text-align: center;
  margin-bottom: 1rem;
  color: white;
}

.comision-label { font-size: 0.8125rem; opacity: 0.85; }
.comision-value { font-size: 2rem; font-weight: 700; margin: 0.25rem 0; }
.comision-detail { font-size: 0.8125rem; opacity: 0.85; }

/* ==================== Menu List ==================== */
.menu-list {
  background: var(--bg-card);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  padding: 0.875rem 1rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--bg-input); }

.menu-icon { font-size: 1.125rem; }
.menu-text { flex: 1; font-weight: 500; }
.menu-arrow { color: var(--text-muted); }

/* ==================== User Card ==================== */
.user-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 14px;
  margin-top: 1.5rem;
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 48px;
  height: 48px;
  background: var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

.user-name { font-weight: 600; }
.user-email { font-size: 0.8125rem; color: var(--text-muted); }

/* ==================== Info Card ==================== */
.info-card {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid var(--border-color);
}

.info-card h4 { margin-bottom: 0.75rem; font-weight: 600; }
.info-card ul { list-style: none; }
.info-card li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.875rem;
}
.info-card li:last-child { border-bottom: none; }

.mini-table { width: 100%; font-size: 0.875rem; }
.mini-table td { padding: 0.5rem 0; border-bottom: 1px solid var(--border-color); }
.mini-table tr:last-child td { border-bottom: none; }

/* ==================== Alerts ==================== */
.alert { padding: 0.875rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ==================== Empty/Error State ==================== */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state p { color: var(--text-muted); margin-bottom: 1rem; }
.error-state { text-align: center; padding: 2rem; color: var(--danger); }

/* ==================== Loading ==================== */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.loading-overlay.hidden { display: none; }

.spinner, .loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-spinner { margin: 3rem auto; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== Toast ==================== */
.toast-container {
  position: fixed;
  top: calc(64px + var(--safe-top));
  left: 1rem; right: 1rem;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.875rem 1rem;
  border-radius: 10px;
  font-weight: 500;
  animation: slideIn 0.2s ease;
  box-shadow: var(--shadow-lg);
}
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--primary); color: white; }

@keyframes slideIn {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==================== Modal ==================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-white);
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body { padding: 1rem; }
.modal-footer { padding: 1rem; border-top: 1px solid var(--border-color); }

.link-box {
  background: var(--bg-input);
  padding: 0.75rem;
  border-radius: 8px;
  word-break: break-all;
  font-size: 0.8125rem;
  font-family: monospace;
}

/* ==================== Call Screen ==================== */
.call-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #111827;
  display: flex;
  flex-direction: column;
  z-index: 200;
}

.call-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  padding-top: calc(1rem + var(--safe-top));
  background: #1f2937;
  color: white;
}
.call-title { font-weight: 600; }

.video-area { flex: 1; display: flex; flex-direction: column; padding: 0.5rem; }

.local-video-wrap {
  width: 100px; height: 75px;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background: #1f2937;
}
.local-video-wrap video { width: 100%; height: 100%; object-fit: cover; }

.video-label {
  position: absolute;
  bottom: 4px; left: 4px;
  background: rgba(0,0,0,0.6);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.625rem;
  color: white;
}

.participants-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.participant-card {
  background: #1f2937;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 16/9;
}
.participant-card video { width: 100%; height: 100%; object-fit: cover; }

.participant-info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  padding: 0.625rem;
  color: white;
}
.participant-name { font-size: 0.8125rem; font-weight: 600; }

.chat-area {
  height: 140px;
  background: #1f2937;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #374151;
}

.chat-header {
  padding: 0.5rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-bottom: 1px solid #374151;
  color: #9ca3af;
  text-transform: uppercase;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chat-msg {
  font-size: 0.75rem;
  background: #374151;
  padding: 0.375rem 0.625rem;
  border-radius: 6px;
  color: white;
}
.chat-user { color: #60a5fa; font-weight: 600; }

.chat-input-wrap {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  border-top: 1px solid #374151;
}

.chat-input-wrap input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: #374151;
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 0.875rem;
  font-family: inherit;
}

.chat-input-wrap button {
  padding: 0.5rem 0.75rem;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: white;
}

.call-controls {
  display: flex;
  justify-content: center;
  gap: 0.875rem;
  padding: 1rem;
  padding-bottom: calc(1rem + var(--safe-bottom));
  background: #1f2937;
}

.control-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  background: #374151;
  color: white;
}
.control-btn.active { background: var(--primary); }
.control-btn.danger { background: var(--danger); }

/* ==================== Action Buttons ==================== */
.action-buttons { display: flex; gap: 0.625rem; margin-bottom: 1.25rem; }
.action-buttons .btn { flex: 1; }

/* ==================== Utilities ==================== */
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.hidden { display: none !important; }
