/* Rosticería POS - Paleta clara y elegante */
:root {
  --bg-primary: #faf9f7;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #2d2a26;
  --text-secondary: #6b6560;
  --accent: #c4a35a;
  --accent-hover: #b8933d;
  --border: #e8e5e1;
  --success: #4a7c59;
  --shadow: 0 2px 12px rgba(45, 42, 38, 0.06);
  --radius: 12px;
  --font: 'DM Sans', -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* Pantalla de login */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-screen.hidden {
  display: none;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 360px;
}

.login-box h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.login-form label {
  display: block;
  margin-bottom: 1rem;
}

.login-form label span {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.login-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 1rem;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-error {
  color: #c44;
  font-size: 0.875rem;
  margin: 0.5rem 0 1rem;
  min-height: 1.25rem;
}

.btn-login {
  width: 100%;
  padding: 0.875rem;
  border: none;
  background: var(--accent);
  color: white;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}

.btn-login:hover {
  background: var(--accent-hover);
}

.btn-logout {
  border-color: #c44;
  color: #c44;
}

.btn-logout:hover {
  background: #c44;
  border-color: #c44;
  color: white;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--bg-secondary);
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.btn-admin {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Main layout */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  padding: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }
}

/* Productos */
.productos {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.productos h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.categorias {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.cat-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.cat-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

.cat-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.productos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.producto-btn {
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.producto-img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--border);
}

.producto-img-placeholder {
  width: 64px;
  height: 64px;
  background: var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-secondary);
}

.producto-btn:hover {
  border-color: var(--accent);
  background: rgba(196, 163, 90, 0.08);
  transform: translateY(-1px);
}

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

.producto-nombre {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
}

.producto-precio {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.25rem;
}

/* Carrito / Ticket */
.carrito {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.carrito-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.carrito-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.btn-limpiar {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-limpiar:hover {
  background: #fee;
  border-color: #fcc;
  color: #c44;
}

.items-carrito {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  list-style: none;
}

.items-carrito:empty::after {
  content: 'Agrega productos al ticket';
  display: block;
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem 0;
  font-size: 0.9rem;
}

.item-carrito {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

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

.item-info {
  flex: 1;
}

.item-nombre {
  font-weight: 500;
}

.item-detalle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.item-acciones {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.item-cantidad {
  min-width: 1.5rem;
  text-align: center;
  font-weight: 600;
}

.btn-mas, .btn-menos {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s;
}

.btn-mas:hover, .btn-menos:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.item-subtotal {
  font-weight: 600;
  min-width: 4rem;
  text-align: right;
  color: var(--accent);
}

.carrito-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: 0 0 var(--radius) var(--radius);
}

.pago-row {
  margin: 0.75rem 0 0.5rem;
}

.pago-row label span {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.pago-row input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 1rem;
}

.cambio-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.9375rem;
}

.cambio-value {
  font-weight: 600;
  color: var(--success);
}

.cambio-value.insuficiente {
  color: #c44;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.total {
  font-size: 1.5rem;
  color: var(--accent);
}

.btn-cobrar {
  width: 100%;
  padding: 1rem;
  border: none;
  background: var(--accent);
  color: white;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cobrar:hover {
  background: var(--accent-hover);
}

.btn-cobrar:disabled {
  background: var(--border);
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(45, 42, 38, 0.4);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal.visible {
  display: flex;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  max-width: 320px;
}

.modal-icon {
  display: inline-flex;
  width: 56px;
  height: 56px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.modal-content h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.btn-modal {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  border: none;
  color: white;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}

.btn-modal:hover {
  background: var(--accent-hover);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
}

.btn-imprimir {
  background: var(--success) !important;
}

.btn-imprimir:hover {
  background: #3d6b4a !important;
}

/* Modal Administrar Productos */
.modal-admin .modal-admin-content {
  background: white;
  border-radius: var(--radius);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.modal-admin-header h2 {
  font-size: 1.25rem;
}

.btn-cerrar-admin {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-primary);
  border-radius: 8px;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.btn-cerrar-admin:hover {
  background: var(--border);
  color: var(--text-primary);
}

.modal-admin-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  overflow-y: auto;
}

@media (max-width: 700px) {
  .modal-admin-body {
    grid-template-columns: 1fr;
  }
}

.admin-form {
  background: var(--bg-primary);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  height: fit-content;
}

.admin-form-hidden {
  display: none;
}

.admin-form-hidden + .admin-lista {
  grid-column: 1 / -1;
}

.admin-form h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.admin-form label {
  display: block;
  margin-bottom: 1rem;
}

.admin-form label span {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.admin-form input,
.admin-form select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.9375rem;
}

.admin-form input:focus,
.admin-form select:focus {
  outline: none;
  border-color: var(--accent);
}

.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.img-preview-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn-quitar-img {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  width: fit-content;
}

.btn-quitar-img:hover {
  background: #fee;
  border-color: #fcc;
  color: #c44;
}

.img-preview {
  margin: 0.75rem 0;
  min-height: 60px;
}

.img-preview img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-cancelar {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.btn-cancelar:hover {
  background: var(--border);
}

.btn-guardar {
  flex: 1;
  padding: 0.6rem 1rem;
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-guardar:hover {
  background: var(--accent-hover);
}

.admin-lista {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.admin-lista-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.admin-lista-header h3 {
  font-size: 1rem;
}

.btn-nuevo {
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-nuevo:hover {
  background: var(--accent);
  color: white;
}

.lista-productos {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.lista-producto-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: white;
}

.lista-producto-item:hover {
  border-color: var(--accent);
}

.lista-producto-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--border);
}

.lista-producto-img-placeholder {
  width: 48px;
  height: 48px;
  background: var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.lista-producto-info {
  flex: 1;
  min-width: 0;
}

.lista-producto-nombre {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lista-producto-detalle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.lista-producto-acciones {
  display: flex;
  gap: 0.5rem;
}

.btn-editar, .btn-eliminar {
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.8125rem;
  cursor: pointer;
}

.btn-editar {
  background: rgba(196, 163, 90, 0.2);
  color: var(--accent-hover);
}

.btn-editar:hover {
  background: var(--accent);
  color: white;
}

.btn-eliminar {
  background: rgba(200, 80, 80, 0.15);
  color: #c44;
}

.btn-eliminar:hover {
  background: #c44;
  color: white;
}

/* Modal Estadísticas */
.modal-stats .modal-stats-content,
.modal-historial .modal-stats-content {
  background: #ffffff;
  background-color: #ffffff;
  border-radius: var(--radius);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.stats-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.stats-filtros {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stats-filtros label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stats-filtros label span {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.stats-filtros select,
.stats-filtros input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.9375rem;
}

.stats-custom {
  display: none;
  gap: 1rem;
  flex-wrap: wrap;
}

.stats-custom.visible {
  display: flex;
}

.btn-ver-stats {
  padding: 0.5rem 1rem;
  background: var(--accent);
  border: none;
  color: white;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-ver-stats:hover {
  background: var(--accent-hover);
}

.stats-resumen {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stats-top h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.stats-table th,
.stats-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.stats-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.stats-table td:nth-child(2),
.stats-table td:nth-child(3) {
  text-align: right;
}

.stats-empty {
  color: var(--text-secondary);
  padding: 1.5rem 0;
  font-size: 0.9rem;
  display: none;
}

.stats-empty.visible {
  display: block;
}

/* Historial */
.historial-body {
  padding: 1.5rem;
  overflow-y: auto;
  background: #ffffff;
}

.historial-filtros {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.historial-filtros label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.historial-filtros label span {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.historial-filtros select,
.historial-filtros input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
}

.historial-custom {
  display: none;
  gap: 1rem;
}

.historial-custom.visible {
  display: flex;
}

.historial-lista {
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
}

.historial-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.historial-item:hover {
  border-color: var(--accent);
  background: rgba(196, 163, 90, 0.06);
}

.historial-item.active {
  border-color: var(--accent);
  background: rgba(196, 163, 90, 0.1);
}

.historial-empty {
  color: var(--text-secondary);
  padding: 1rem;
  font-size: 0.9rem;
  list-style: none;
}

.historial-item-info {
  font-size: 0.9375rem;
}

.historial-item-id {
  font-weight: 600;
}

.historial-item-fecha {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.historial-item-total {
  font-weight: 600;
  color: var(--accent);
}

.historial-detalle {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-primary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.historial-detalle:empty::before {
  content: 'Selecciona una venta para ver el detalle';
  color: var(--text-secondary);
}

.historial-detalle h4 {
  font-size: 0.9375rem;
  margin-bottom: 0.75rem;
}

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

.historial-detalle th,
.historial-detalle td {
  padding: 0.4rem 0;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.historial-detalle .btn-imprimir-orden {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
}

/* Ticket impresión */
.ticket-print {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 280px;
  font-family: monospace;
  font-size: 12px;
  padding: 1rem;
  background: white;
  color: black;
}

@media print {
  body * { visibility: hidden; }
  #ticket-print, #ticket-print * { visibility: visible !important; }
  #ticket-print {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 280px !important;
    z-index: 99999 !important;
  }
}
