/* Reset y Variables */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #3b82f6;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --dark: #1e293b;
  --light: #f8fafc;
  --border: #e2e8f0;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #f1f5f9;
  color: #334155;
  line-height: 1.6;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-box {
  background: white;
  border-radius: 15px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 40px;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header i {
  font-size: 50px;
  color: var(--primary);
  margin-bottom: 10px;
}

.login-header h1 {
  color: var(--dark);
  margin-bottom: 5px;
}

.login-header p {
  color: var(--secondary);
  font-size: 14px;
}

.login-form {
  margin: 20px 0;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--secondary);
}

.login-footer hr {
  margin: 15px 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* Layout Principal */
.wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--dark);
  color: white;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 25px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
  font-size: 20px;
}

.sidebar-menu {
  padding: 15px 0;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: #cbd5e1;
  text-decoration: none;
  transition: all 0.3s;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  padding-left: 25px;
}

.menu-item i {
  margin-right: 10px;
  width: 20px;
}

.menu-item.logout {
  margin-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #fca5a5;
}

.main-content {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: white;
  padding: 20px 30px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar h1 {
  font-size: 24px;
  color: var(--dark);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--secondary);
}

.user-info i {
  font-size: 24px;
}

.content {
  flex: 1;
  padding: 30px;
}

.footer {
  background: white;
  padding: 15px 30px;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--secondary);
  font-size: 14px;
}

/* Alertas */
.alert {
  padding: 15px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert i {
  font-size: 20px;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border-left: 4px solid var(--success);
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid var(--danger);
}

/* Cards */
.card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  padding: 25px;
  margin-bottom: 20px;
}

.card h3 {
  color: var(--dark);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.3s;
}

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

.btn-primary:hover {
  background: #2563eb;
}

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

.btn-success:hover {
  background: #059669;
}

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

.btn-danger:hover {
  background: #dc2626;
}

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

.btn-info:hover {
  background: #0891b2;
}

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

.btn-secondary:hover {
  background: #475569;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* Formularios */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--dark);
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 30px;
}

.form-control {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead {
  background: #f8fafc;
}

.table th,
.table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-weight: 600;
  color: var(--dark);
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table .actions {
  display: flex;
  gap: 5px;
}

.text-center {
  text-align: center;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #cffafe;
  color: #164e63;
}

.badge-secondary {
  background: #f1f5f9;
  color: #475569;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.page-header h2 {
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.metric-card {
  background: white;
  border-radius: 10px;
  padding: 25px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  display: flex;
  gap: 20px;
  align-items: center;
}

.metric-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
}

.card-blue .metric-icon {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.card-green .metric-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.card-orange .metric-icon {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.card-red .metric-icon {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.metric-info h3 {
  font-size: 14px;
  color: var(--secondary);
  margin-bottom: 5px;
}

.metric-value {
  font-size: 24px;
  font-weight: bold;
  color: var(--dark);
  margin: 0;
}

.metric-info small {
  font-size: 12px;
  color: var(--secondary);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.dashboard-card {
  background: white;
  border-radius: 10px;
  padding: 25px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.dashboard-card h3 {
  color: var(--dark);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.info-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.info-card {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.info-card h4 {
  font-size: 14px;
  color: var(--secondary);
  margin-bottom: 10px;
}

.info-card .value {
  font-size: 22px;
  font-weight: bold;
  color: var(--dark);
}

/* Ventas */
.venta-container {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 20px;
}

.venta-productos {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.productos-lista {
  max-height: 500px;
  overflow-y: auto;
}

.producto-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  transition: all 0.3s;
}

.producto-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.producto-info {
  flex: 1;
}

.producto-codigo {
  display: block;
  font-size: 12px;
  color: var(--secondary);
}

.producto-precio {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-right: 15px;
}

.producto-precio .stock {
  font-size: 12px;
  color: var(--secondary);
}

.agregar-producto {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.venta-resumen {
  position: sticky;
  top: 20px;
}

.tabla-venta {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.cantidad-input {
  width: 60px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.totales-venta {
  border-top: 2px solid var(--border);
  padding-top: 15px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 16px;
}

.total-final {
  font-size: 20px;
  font-weight: bold;
  color: var(--primary);
  padding-top: 10px;
  border-top: 2px solid var(--primary);
}

.input-descuento {
  width: 100px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Filtros */
.filtros {
  background: #f8fafc;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.filtros-form {
  display: flex;
  gap: 15px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filtros-form .form-group {
  margin-bottom: 0;
}

.filtros-form label {
  font-size: 13px;
  margin-bottom: 5px;
}

.filtros-form input,
.filtros-form select {
  padding: 8px 12px;
}

/* Compras */
.compra-container {
  max-width: 900px;
}

.compra-form {
  width: 100%;
}

.tabla-compra {
  margin: 20px 0;
}

.precio-input {
  width: 100px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.totales-compra {
  text-align: right;
  padding: 15px 0;
  border-top: 2px solid var(--border);
}

/* Alert Row */
.alert-row {
  background: #fef2f2 !important;
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }

  .main-content {
    margin-left: 200px;
  }

  .venta-container {
    grid-template-columns: 1fr;
  }

  .venta-resumen {
    position: static;
  }

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

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

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    z-index: 1000;
    transition: left 0.3s;
  }

  .main-content {
    margin-left: 0;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .content {
    padding: 15px;
  }

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

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

  .page-header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

  .filtros-form {
    flex-direction: column;
    align-items: stretch;
  }

  .filtros-form .form-group {
    width: 100%;
  }
}

/* Estilos adicionales para mejorar la interfaz */
canvas {
  max-height: 300px;
}

.empty-message {
  font-style: italic;
  color: var(--secondary);
}

/* Animaciones */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert {
  animation: fadeIn 0.3s ease-in-out;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Mejoras visuales */
.table tbody tr {
  transition: background-color 0.2s;
}

.btn {
  transition: all 0.2s;
}

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

input:disabled,
select:disabled,
textarea:disabled {
  background-color: #f1f5f9;
  cursor: not-allowed;
}

/* Estado de carga */
.loading {
  pointer-events: none;
  opacity: 0.6;
}

/* Print styles */
@media print {
  .sidebar,
  .topbar,
  .footer,
  .page-header,
  .btn,
  .no-print {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
  }

  .card {
    box-shadow: none;
    page-break-inside: avoid;
  }
}
