/* =============================================
   CELFIX PRO – Styles
   ============================================= */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --orange: #f97316;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --sidebar-w: 240px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md: 0 4px 24px rgba(0,0,0,.10);
  --transition: .2s ease;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--text);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition), width var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  color: #fff;
}
.logo i { color: var(--primary); font-size: 1.4rem; }
.logo strong { color: var(--primary); }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px;
  border-radius: 6px;
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: #fff; }

.sidebar-nav {
  flex: 1;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-light);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: all var(--transition);
}
.nav-item i { width: 18px; text-align: center; font-size: 1rem; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }

.sidebar-footer {
  padding: 16px;
  font-size: .75rem;
  color: var(--text-light);
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ===================== MAIN WRAPPER ===================== */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ===================== TOPBAR ===================== */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.topbar-actions { display: flex; gap: 10px; }

/* ===================== SECTIONS ===================== */
.section {
  display: none;
  padding: 28px 28px;
  flex: 1;
  animation: fadeIn .25s ease;
}
.section.active { display: block; }

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

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.page-header p  { color: var(--text-muted); margin-top: 4px; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline  { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-success  { background: var(--success); color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-icon { padding: 7px 10px; }

/* ===================== STAT CARDS ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}
.stat-card.blue   { border-color: var(--primary); }
.stat-card.orange { border-color: var(--orange); }
.stat-card.green  { border-color: var(--success); }
.stat-card.purple { border-color: var(--purple); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-card.blue   .stat-icon { background: #e0e7ff; color: var(--primary); }
.stat-card.orange .stat-icon { background: #ffedd5; color: var(--orange); }
.stat-card.green  .stat-icon { background: #d1fae5; color: var(--success); }
.stat-card.purple .stat-icon { background: #ede9fe; color: var(--purple); }

.stat-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}
.stat-label {
  display: block;
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===================== DASHBOARD GRID ===================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

/* ===================== CARDS ===================== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--text); }
.card-header h2 i { color: var(--primary); }
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }

/* ===================== STATUS SUMMARY ===================== */
.status-summary { display: flex; flex-direction: column; gap: 12px; }
.status-item { display: flex; flex-direction: column; gap: 4px; }
.status-item-header { display: flex; justify-content: space-between; font-size: .85rem; }
.status-item-label { font-weight: 500; }
.status-item-count { color: var(--text-muted); }
.status-bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.status-bar-fill { height: 100%; border-radius: 99px; transition: width .6s ease; }

/* ===================== RECENT REPAIRS ===================== */
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: var(--surface-2); border-radius: var(--radius-sm); padding-left: 8px; }
.recent-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff;
  flex-shrink: 0;
}
.recent-info { flex: 1; min-width: 0; }
.recent-name { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-device { font-size: .78rem; color: var(--text-muted); }
.recent-right { text-align: right; flex-shrink: 0; }
.recent-order { font-size: .78rem; color: var(--text-muted); }

/* ===================== FILTERS BAR ===================== */
.filters-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  flex: 1;
  min-width: 200px;
}
.search-box i { color: var(--text-muted); }
.search-box input {
  border: none; outline: none;
  background: transparent;
  font-family: inherit;
  font-size: .88rem;
  color: var(--text);
  padding: 10px 0;
  width: 100%;
}
.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: inherit;
  font-size: .85rem;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--primary); }

/* ===================== TABLE ===================== */
.table-responsive { overflow-x: auto; }

.repairs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.repairs-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.repairs-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.repairs-table tr:last-child td { border-bottom: none; }
.repairs-table tbody tr:hover { background: var(--surface-2); }

.order-number {
  font-weight: 700;
  color: var(--primary);
  font-size: .8rem;
  background: var(--primary-light);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.device-info { line-height: 1.4; }
.device-brand { font-weight: 600; }
.device-model { color: var(--text-muted); font-size: .8rem; }

.problem-cell {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.table-actions { display: flex; gap: 6px; }

/* ===================== BADGES ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-recibido       { background: #dbeafe; color: #1d4ed8; }
.badge-diagnostico    { background: #fef3c7; color: #92400e; }
.badge-reparacion     { background: #ede9fe; color: #6d28d9; }
.badge-repuestos      { background: #ffedd5; color: #9a3412; }
.badge-listo          { background: #d1fae5; color: #065f46; }
.badge-entregado      { background: #f0fdf4; color: #166534; }
.badge-cancelado      { background: #fee2e2; color: #991b1b; }

.priority-badge { border-radius: 6px; padding: 3px 8px; font-size: .72rem; }
.priority-baja     { background: #f1f5f9; color: #64748b; }
.priority-normal   { background: #dbeafe; color: #1d4ed8; }
.priority-alta     { background: #fef3c7; color: #92400e; }
.priority-urgente  { background: #fee2e2; color: #991b1b; }

/* ===================== PAGINATION ===================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px;
  border-top: 1px solid var(--border);
}
.page-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===================== FORM ===================== */
.repair-form { max-width: 960px; }

.form-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.form-section-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.form-section-title i { color: var(--primary); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: .82rem; font-weight: 500; color: var(--text-muted); }

.form-group input,
.form-group select,
.form-group textarea {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: inherit;
  font-size: .88rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  resize: vertical;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ===================== MODAL ===================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  z-index: 1000;
  animation: fadeIn .2s ease;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 90%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp .25s ease;
}
.confirm-modal { max-width: 400px; }

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

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 1.1rem; padding: 4px 8px;
  border-radius: 6px; transition: color var(--transition);
}
.modal-close:hover { color: var(--danger); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Detail grid in modal */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.detail-item { display: flex; flex-direction: column; gap: 3px; }
.detail-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.detail-value { font-size: .9rem; color: var(--text); font-weight: 500; }
.detail-section { margin-bottom: 20px; }
.detail-section h3 { font-size: .88rem; font-weight: 700; color: var(--text-muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 6px; }
.detail-section h3 i { color: var(--primary); }
.detail-text { font-size: .875rem; color: var(--text); line-height: 1.6; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; border: 1px solid var(--border); }

/* ===================== TOAST ===================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 260px;
  font-size: .875rem;
  animation: slideInRight .25s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text); }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===================== EMPTY / MISC ===================== */
.empty-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
  padding: 32px 0;
}

.loading-row td { text-align: center; padding: 40px; color: var(--text-muted); }

/* ===================== SIDEBAR COLLAPSED ===================== */
body.sidebar-collapsed .sidebar { width: 64px; }
body.sidebar-collapsed .sidebar .logo span,
body.sidebar-collapsed .sidebar .nav-item span,
body.sidebar-collapsed .sidebar .sidebar-footer { display: none; }
body.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 11px; }
body.sidebar-collapsed .main-wrapper { margin-left: 64px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vw rgba(0,0,0,.35); }
  .main-wrapper { margin-left: 0; }
  .menu-btn { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .section { padding: 16px; }
  body.sidebar-collapsed .main-wrapper { margin-left: 0; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; }
  .search-box, .filter-select { width: 100%; }
  .topbar-actions .btn span { display: none; }
}
