/* --- ESTILOS COMPARTIDOS --- */
:root {
  --primary-color: #4361ee;
  --primary-light: rgba(67, 97, 238, 0.1);
  --secondary-color: #2ec4b6;
  --danger-color: #e63946;
  --background-color: #f8f9fa;
  --sidebar-color: #1e1e2d;
  --text-light: #f8f9fa;
  --text-dark: #2b2d42;
  --card-bg: rgba(255, 255, 255, 0.85);
  --warning-color: #ff9f1c;
  --info-color: #4cc9f0;
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background-color);
  line-height: 1.6;
}

.dashboard-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background-color: var(--sidebar-color);
  color: var(--text-light);
  padding: 20px;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 30px;
  color: var(--primary-color);
  display: flex;
  justify-content: center;
}

.logo img {
    border-radius: 50%;
    object-fit: cover;
    aspect-ratio: 1 / 1;
    width: 150px;
    height: 150px;
    border: 3px solid rgba(255, 255, 255, 0.1);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  color: var(--text-light);
  text-decoration: none;
  border-radius: 12px;
  margin-bottom: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.sidebar-nav a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateX(5px);
  color: var(--primary-color);
}

.sidebar-nav a.active {
  background-color: var(--primary-light);
  color: var(--primary-color);
  border-color: rgba(67, 97, 238, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.sidebar-nav a i {
  margin-right: 12px;
  width: 20px;
  text-align: center;
}

.main-content {
  flex-grow: 1;
  padding: 30px;
}

.content-section {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 30px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  margin-bottom: 25px;
  transition: transform 0.3s ease;
}

.content-section:not(.active) {
  display: none;
}

h2 {
  color: var(--sidebar-color);
  margin-bottom: 25px;
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}

h2 i {
  margin-right: 10px;
  color: var(--primary-color);
}

/* --- Formularios y Elementos --- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.form-grid.single-col {
  grid-template-columns: 1fr;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: 8px;
  font-weight: 600;
  color: #555;
}

input:not([type="checkbox"]),
select {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 16px;
  transition: border-color 0.3s;
}

input:focus,
select:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:active {
  transform: scale(0.95);
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary-color), #3a0ca3);
  color: white;
  box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(67, 97, 238, 0.4);
}

.secondary-btn {
  background: linear-gradient(135deg, var(--secondary-color), #27a89b);
  color: white;
  box-shadow: 0 4px 15px rgba(46, 196, 182, 0.3);
}

.secondary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(46, 196, 182, 0.4);
}

.danger-btn {
  background: linear-gradient(135deg, var(--danger-color), #c1121f);
  color: white;
  box-shadow: 0 4px 15px rgba(230, 57, 70, 0.3);
}

.danger-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(230, 57, 70, 0.4);
}

.full-width {
  grid-column: 1 / -1;
  margin-top: 10px;
}

/* --- Mensajes y Advertencias --- */
.status-message {
  margin-top: 20px;
  padding: 15px;
  border-radius: 4px;
  font-weight: bold;
  display: none;
}

.status-message.success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.status-message.error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.status-message.info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.status-message.warning {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
}

/* Filtro de Producto (Mostrar detalles) */
.product-details {
  margin-top: 15px;
  padding: 15px;
  border-left: 5px solid var(--primary-color);
  background-color: #f8f9fa;
  border-radius: 4px;
}

.product-details p {
  margin: 5px 0;
}

.product-details.hidden {
  display: none;
}

/* Tablas */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

.data-table th,
.data-table td {
  border: 1px solid #ddd;
  padding: 12px;
  text-align: left;
}

.data-table th {
  background-color: #f2f2f2;
  font-weight: 700;
  color: #333;
}

.data-table tr:nth-child(even) {
  background-color: #f9f9f9;
}

/* Gráficos */
.chart-container {
  width: 100%;
  height: 400px;
  margin: 20px 0;
}

/* Dashboard Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  text-align: center;
  border-left: 4px solid;
}

.stat-card.ventas {
  border-color: var(--primary-color);
}

.stat-card.compras {
  border-color: var(--info-color);
}

.stat-card.ganancias {
  border-color: var(--secondary-color);
}

.stat-card.gastos {
  border-color: var(--danger-color);
}

.stat-value {
  font-size: 2rem;
  font-weight: bold;
  margin: 10px 0;
}

.stat-label {
  color: #666;
  font-size: 0.9rem;
}

/* Responsivo */
@media (max-width: 768px) {
  .dashboard-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    padding: 15px 20px;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .sidebar .logo {
    margin-bottom: 0;
  }

  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 5px;
  }

  .sidebar-nav a {
    padding: 8px 10px;
    flex-shrink: 0;
  }

  .main-content {
    padding: 20px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

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

/* --- Sistema de Pedidos Pro --- */
.order-header {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  background: rgba(255, 255, 255, 0.4);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  margin-bottom: 20px;
}

.order-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  margin-top: 15px;
}

.order-table th {
  text-align: left;
  padding: 12px;
  color: var(--text-dark);
  font-weight: 600;
  border-bottom: 2px solid #ddd;
}

.order-table td {
  padding: 10px 12px;
  background: white;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
}

.order-table td:first-child {
  border-left: 1px solid #eee;
  border-radius: 8px 0 0 8px;
}

.order-table td:last-child {
  border-right: 1px solid #eee;
  border-radius: 0 8px 8px 0;
}

.totals-section {
  float: right;
  width: 300px;
  margin-top: 25px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  border: 1px solid var(--glass-border);
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.total-row.grand-total {
  border-bottom: none;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary-color);
  margin-top: 10px;
}

.line-actions {
  display: flex;
  gap: 15px;
  margin-top: 15px;
  border-top: 1px dashed #ccc;
  padding-top: 15px;
}

.remove-line {
  color: var(--danger-color);
  cursor: pointer;
  transition: opacity 0.2s;
}

.remove-line:hover {
  opacity: 0.7;
}

/* --- Estilos para Citas y Cotizaciones (FASE 3) --- */
.tab-btn {
  padding: 12px 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: #666;
  border-bottom: 3px solid transparent;
  transition: all 0.3s;
}

.tab-btn:hover {
  color: var(--primary-color);
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.3s ease;
}

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

.badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.badge-pendiente {
  background: #fff3cd;
  color: #856404;
}

.badge-confirmada {
  background: #d1ecf1;
  color: #0c5460;
}

.badge-atendida {
  background: #d4edda;
  color: #155724;
}

/* --- Botones de Acción en Tablas --- */
.btn-action {
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-action.btn-success {
  background-color: #28a745;
  color: white;
}

.btn-action.btn-success:hover {
  background-color: #218838;
}

.btn-action.btn-warning {
  background-color: #ffc107;
  color: #212529;
}

.btn-action.btn-warning:hover {
  background-color: #e0a800;
}

.btn-action.btn-danger {
  background-color: #dc3545;
  color: white;
}

.btn-action.btn-danger:hover {
  background-color: #c82333;
}

/* --- KPI Cards --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.kpi-card {
  background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-left: 4px solid;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.kpi-card.primary {
  border-left-color: var(--primary-color);
}

.kpi-card.success {
  border-left-color: #28a745;
}

.kpi-card.warning {
  border-left-color: #ffc107;
}

.kpi-card.danger {
  border-left-color: #dc3545;
}

.kpi-titulo {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 8px;
  font-weight: 500;
}

.kpi-valor {
  font-size: 2rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 5px;
}

.kpi-icono {
  font-size: 2.5rem;
  opacity: 0.15;
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.kpi-card {
  position: relative;
  overflow: hidden;
}