/* Complete redesign with modern dark theme and professional styling */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Dark theme colors */
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --bg-card: #161616;
  --bg-hover: #1f1f1f;

  /* Text colors */
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;

  /* Accent colors */
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;

  /* Border colors */
  --border-primary: #2a2a2a;
  --border-secondary: #333333;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);

  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Login Page */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%);
  padding: 20px;
}

.login-box {
  background: var(--bg-card);
  padding: 48px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}

.login-box h2 {
  text-align: center;
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.login-box p {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 24px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: var(--bg-secondary);
}

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

/* Buttons */
.btn {
  padding: 12px 24px;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn-success {
  background: var(--accent-green);
}

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

.btn-danger {
  background: var(--accent-red);
}

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

.btn-warning {
  background: var(--accent-orange);
  color: white;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

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

/* Dashboard Layout */
.dashboard {
  display: flex;
  min-height: 100vh;
  background: var(--bg-primary);
}

.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
  padding: 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 3px;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-primary);
}

.sidebar-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.sidebar-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.sidebar-menu {
  list-style: none;
  padding: 12px 8px;
}

.sidebar-menu li {
  margin-bottom: 4px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
}

.sidebar-menu a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-menu a.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-left: 3px solid var(--accent-blue);
}

.main-content {
  margin-left: 260px;
  flex: 1;
  padding: 24px;
  width: calc(100% - 260px);
  min-height: 100vh;
}

.top-bar {
  background: var(--bg-card);
  padding: 20px 24px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border-primary);
}

.top-bar h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info span {
  color: var(--text-secondary);
  font-size: 14px;
}

.logout-btn {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: white;
}

/* Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  transition: all 0.2s;
}

.stat-card:hover {
  border-color: var(--border-secondary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card h3 {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.stat-card .value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.stat-card .label {
  font-size: 14px;
  color: var(--text-secondary);
}

.stat-card.blue {
  border-left: 3px solid var(--accent-blue);
}

.stat-card.green {
  border-left: 3px solid var(--accent-green);
}

.stat-card.orange {
  border-left: 3px solid var(--accent-orange);
}

.stat-card.red {
  border-left: 3px solid var(--accent-red);
}

.stat-card.purple {
  border-left: 3px solid var(--accent-purple);
}

/* Content Box */
.content-box {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  margin-bottom: 24px;
}

.content-box h2 {
  margin-bottom: 24px;
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

/* Table */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-primary);
}

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

table thead {
  background: var(--bg-tertiary);
}

table th,
table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-primary);
  font-size: 14px;
}

table th {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

table td {
  color: var(--text-primary);
}

table tbody tr {
  transition: background 0.2s;
}

table tbody tr:hover {
  background: var(--bg-hover);
}

table tbody tr:last-child td {
  border-bottom: none;
}

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

.search-box {
  margin-bottom: 20px;
}

.search-box input {
  width: 100%;
  max-width: 400px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.modal.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--bg-card);
  padding: 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-primary);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 4px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-primary);
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.close-modal {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-modal:hover {
  color: var(--text-primary);
}

/* Alert */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 14px;
  border: 1px solid;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  border-color: rgba(16, 185, 129, 0.3);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.3);
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.3);
}

/* Venta */
.venta-container {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
}

.productos-venta {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
}

.carrito-venta {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  position: sticky;
  top: 24px;
  height: fit-content;
}

.producto-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border-primary);
  transition: background 0.2s;
}

.producto-item:hover {
  background: var(--bg-hover);
}

.producto-item:last-child {
  border-bottom: none;
}

.total-venta {
  font-size: 32px;
  font-weight: 700;
  text-align: right;
  margin: 24px 0;
  color: var(--accent-green);
  letter-spacing: -1px;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-green);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-orange);
}

.badge-info {
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent-blue);
}

/* Action buttons in tables */
.action-buttons {
  display: flex;
  gap: 8px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 14px;
}

/* Loading spinner */
.spinner {
  border: 3px solid var(--border-primary);
  border-top: 3px solid var(--accent-blue);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .venta-container {
    grid-template-columns: 1fr;
  }

  .carrito-venta {
    position: relative;
    top: 0;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-primary);
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 16px;
  }

  .top-bar {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

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

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

  .login-box {
    padding: 32px 24px;
  }
}

@media (max-width: 576px) {
  .content-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .btn-block {
    width: 100%;
  }

  table {
    font-size: 13px;
  }

  table th,
  table td {
    padding: 10px 12px;
  }
}

/* Print styles for boletas */
@media print {
  body {
    background: white;
    color: black;
  }

  .sidebar,
  .top-bar,
  .btn,
  .no-print {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }
}
