/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #f4f6f9;
  color: #2c3e50;
  min-height: 100vh;
}
a { color: #3498db; text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; font-size: 13px; border: none; padding: 6px 14px; border-radius: 6px; transition: all 0.2s ease; }
input, select, textarea { font-family: inherit; font-size: 14px; border: 1px solid #dee2e6; border-radius: 6px; padding: 7px 10px; outline: none; transition: border-color 0.2s; }
input:focus, select:focus, textarea:focus { border-color: #3498db; box-shadow: 0 0 0 2px rgba(52,152,219,0.15); }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #bdc3c7; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #95a5a6; }

/* ========== HEADER / NAVBAR ========== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, #1a2a4a, #2c3e6b);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 48px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-title { font-size: 16px; font-weight: 600; white-space: nowrap; }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-user { font-size: 12px; color: rgba(255,255,255,0.6); }

/* Nav links */
.nav-links { display: flex; gap: 0; height: 100%; align-items: stretch; }
.nav-link {
  display: flex; align-items: center;
  color: rgba(255,255,255,0.7); text-decoration: none;
  padding: 0 16px; height: 48px; font-size: 14px; font-weight: 500;
  border-bottom: 3px solid transparent; transition: all 0.2s;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.08); text-decoration: none; }
.nav-link.active { color: #fff; background: rgba(255,255,255,0.12); border-bottom-color: #3498db; }

/* Admin dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle { cursor: pointer; }
.nav-dropdown-menu {
  display: none; position: absolute; top: 48px; right: 0;
  background: #1a2a4a; min-width: 200px; z-index: 101;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3); border-radius: 0 0 8px 8px;
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block; padding: 10px 20px; color: rgba(255,255,255,0.8);
  font-size: 13px; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.nav-dropdown-menu a:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* Hamburger */
.hamburger { display: none; background: none; color: #fff; font-size: 22px; padding: 4px 8px; }
.mobile-menu {
  display: none; position: absolute; top: 48px; left: 0; right: 0;
  background: #1a2a4a; flex-direction: column; z-index: 99;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.mobile-menu a {
  display: block; padding: 12px 24px; color: rgba(255,255,255,0.8);
  text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 14px;
}
.mobile-menu a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.mobile-menu a.active { color: #fff; background: rgba(255,255,255,0.12); }
.mobile-menu.open { display: flex; }

@media(max-width:767px){
  .nav-links { display: none; }
  .hamburger { display: block; }
}

/* ========== MAIN CONTENT ========== */
.main { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* ========== BUTTONS ========== */
.btn-primary { background: #3498db; color: #fff; }
.btn-primary:hover { background: #2980b9; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-neutral { background: #95a5a6; color: #fff; }
.btn-neutral:hover { background: #7f8c8d; }
.btn-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #229954; }
.btn-sm { font-size: 12px; padding: 4px 10px; }
.btn-warning { background: #f39c12; color: #fff; }
.btn-warning:hover { background: #e67e22; }

/* ========== BADGES / PILLS ========== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap;
}
.badge-lead, .badge-potencial { background: #3498db; }
.badge-cliente { background: #27ae60; }
.badge-baja, .badge-bajo { background: #95a5a6; }
.badge-media, .badge-medio { background: #f39c12; }
.badge-alta, .badge-alto { background: #e67e22; }
.badge-activo { background: #27ae60; }
.badge-inactivo { background: #95a5a6; }
.badge-pendiente { background: #f39c12; }
.badge-entregado { background: #27ae60; }
.badge-cancelado { background: #e74c3c; }
.badge-si { background: #e74c3c; }
.badge-no { background: #27ae60; }
.badge-logistica { background: #8e44ad; font-size: 11px; padding: 2px 8px; }

/* ========== TABLES ========== */
.table-wrap { overflow-x: auto; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
thead th {
  background: #ecf0f1; color: #2c3e50; font-weight: 600; text-align: left;
  padding: 10px 12px; font-size: 13px; border-bottom: 2px solid #dee2e6;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid #dee2e6; vertical-align: middle; font-size: 13px; }
tbody tr:nth-child(even) { background: #f8f9fa; }
tbody tr:hover { background: #eef3f8; }

.action-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* ========== SECTION TITLE ========== */
.section-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.date-group { margin-bottom: 24px; }
.date-label {
  font-size: 15px; font-weight: 600; margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.date-badge { font-size: 12px; background: #dee2e6; color: #555; padding: 2px 10px; border-radius: 10px; font-weight: 500; }

/* ========== MASS SEND BAR ========== */
.mass-send {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; background: #ecf0f1; border-radius: 8px; margin-bottom: 20px; font-size: 13px;
}
.mass-send select { font-size: 13px; padding: 5px 8px; }

/* ========== CHECKBOXES ========== */
.row-check { width: 18px; height: 18px; accent-color: #3498db; cursor: pointer; }

/* ========== CANAL SELECT ========== */
.sofist-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.canal-select { font-size: 12px; padding: 3px 6px; border-radius: 4px; border: 1px solid #ccc; background: #fff; }

/* ========== SEARCH BAR ========== */
.search-bar { margin-bottom: 14px; }
.search-bar input { width: 100%; max-width: 350px; }

/* ========== MODALS ========== */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 200; justify-content: center; align-items: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 12px; padding: 24px; position: relative;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  animation: modalIn 0.2s ease;
  width: 90vw; max-width: 500px;
}
.modal.wide { max-width: 680px; }
@keyframes modalIn { from { opacity:0; transform:scale(0.95); } to { opacity:1; transform:scale(1); } }
.modal-close {
  position: absolute; top: 12px; right: 14px; background: none; color: #999;
  font-size: 20px; padding: 2px 6px; border-radius: 4px;
}
.modal-close:hover { color: #333; background: #f0f0f0; }
.modal h3 { font-size: 18px; margin-bottom: 16px; padding-right: 28px; }
.modal-subtitle { color: #888; font-size: 13px; margin: -10px 0 14px; }

/* ========== CALENDAR ========== */
.calendar { user-select: none; }
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-header button { background: none; font-size: 18px; color: #555; padding: 4px 10px; border-radius: 4px; }
.cal-header button:hover { background: #eee; }
.cal-header span { font-weight: 600; font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; text-align: center; }
.cal-day-name { font-size: 11px; font-weight: 600; color: #888; padding: 6px 0; }
.cal-day {
  padding: 8px 0; border-radius: 6px; cursor: pointer; font-size: 13px; transition: all 0.15s;
}
.cal-day:hover { background: #e8f4fd; }
.cal-day.today { background: #3498db; color: #fff; font-weight: 700; }
.cal-day.selected { background: #2980b9; color: #fff; font-weight: 700; }
.cal-day.empty { cursor: default; }
.cal-day.empty:hover { background: none; }
.cal-confirm { margin-top: 14px; text-align: center; }

/* ========== ORDER MODAL TABLE ========== */
.order-table td { padding: 6px 8px; font-size: 13px; }
.order-table th { padding: 6px 8px; font-size: 12px; }
.order-add-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 12px 0; font-size: 13px; }
.order-add-bar input, .order-add-bar select { flex: 1; min-width: 120px; }
.order-summary { border-top: 2px solid #dee2e6; padding-top: 12px; margin-top: 8px; }
.order-summary-line { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 14px; }
.order-summary-line.total { font-weight: 700; font-size: 16px; }

/* ========== NOTES MODAL ========== */
.note-item { padding: 10px 0; border-bottom: 1px solid #eee; }
.note-item:last-child { border: none; }
.note-date { font-size: 11px; color: #999; margin-bottom: 3px; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: #555; }
.form-group input, .form-group select, .form-group textarea { width: 100%; }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: #3498db; }
.form-check label { font-weight: 500; font-size: 13px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ========== LOGIN ========== */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #1a2a4a, #2c3e6b);
}
.login-box {
  background: #fff; border-radius: 12px; padding: 40px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  width: 90vw; max-width: 400px; text-align: center;
}
.login-box h1 { font-size: 24px; margin-bottom: 8px; color: #2c3e50; }
.login-box p { color: #888; font-size: 14px; margin-bottom: 24px; }
.login-box .form-group { text-align: left; }
.login-box input { text-align: center; font-size: 18px; letter-spacing: 2px; }
.login-box button { width: 100%; padding: 12px; font-size: 16px; margin-top: 10px; }
.login-error { color: #e74c3c; font-size: 13px; margin-top: 8px; }

/* ========== ALERTS ========== */
.alert {
  padding: 10px 16px; border-radius: 8px; margin-bottom: 16px;
  font-size: 13px; display: flex; align-items: center; gap: 8px;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ========== SESSION CLOSED ========== */
.session-closed { text-align: center; padding: 80px 20px; color: #888; font-size: 18px; }

/* ========== RESPONSIVE: MOBILE CARDS ========== */
@media(max-width:767px){
  .main { padding: 12px; }
  .modal { width: 95vw; max-width: none; padding: 18px; }
  .form-row { flex-direction: column; }
  .form-row .form-group { min-width: 100%; }

  .responsive-table thead { display: none; }
  .responsive-table tbody tr {
    display: block; background: #fff; margin-bottom: 10px;
    border-radius: 8px; padding: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  }
  .responsive-table tbody td {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border: none; font-size: 13px;
  }
  .responsive-table tbody td::before {
    content: attr(data-label);
    font-weight: 600; color: #888; font-size: 12px; margin-right: 10px; white-space: nowrap;
  }
  .action-btns { flex-direction: column; width: 100%; }
  .action-btns button, .action-btns a { width: 100%; text-align: center; }
  .mass-send { font-size: 12px; }
}

@media(min-width:768px) and (max-width:1024px){
  table { font-size: 13px; }
  .btn-sm { font-size: 11px; padding: 3px 8px; }
}
