:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-color: #64748b;
  --success-color: #22c55e;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #06b6d4;
  --bg-color: #f8fafc;
  --sidebar-bg: #1e293b;
  --sidebar-text: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --radius: 0.75rem;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --sidebar-collapsed-width: 70px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Image Modal / Lightbox */
.image-modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  cursor: zoom-out;
  align-items: center;
  justify-content: center;
}

.image-modal img {
  max-width: 90%;
  max-height: 90%;
  border-radius: var(--radius);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease;
}

.image-modal.active {
  display: flex;
}
/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, all 0.3s ease;
  flex-shrink: 0;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 2rem 1.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0 1rem;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.875rem 1rem;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-radius: var(--radius);
  margin-bottom: 0.25rem;
  transition: all 0.2s;
}

.nav-item:hover,
.nav-item.active {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-item i,
.nav-item iconify-icon {
  width: 24px;
  height: 24px;
  margin-right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Submenú desplegable */
.nav-submenu {
  margin-bottom: 0.25rem;
}

.nav-toggle {
  position: relative;
  justify-content: space-between;
}

.nav-section {
  padding: 1.5rem 1.5rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: opacity 0.3s;
}

.sidebar-collapsed .nav-section {
  padding: 1rem 0;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0;
  height: 1px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.submenu-arrow {
  margin-left: auto;
  margin-right: 0;
  width: auto !important;
  transition: transform 0.3s ease;
  font-size: 0.75rem;
}

.nav-toggle.active .submenu-arrow {
  transform: rotate(180deg);
}

/* Sidebar Collapsed State */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-header span,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .sidebar-nav .badge,
.sidebar-collapsed .nav-submenu .submenu-arrow {
  display: none !important;
}

.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: 1.5rem 0;
}

.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 1rem;
}

.sidebar-collapsed .nav-item iconify-icon {
  margin-right: 0;
  font-size: 1.5rem;
}

.sidebar-collapsed .nav-submenu .submenu-items {
  display: none !important;
}

/* Sidebar Backdrop for Mobile/Tablet */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-active .sidebar-overlay {
  display: block;
  opacity: 1;
}

.submenu-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding-left: 1rem;
}

.submenu-items.show {
  max-height: 500px;
}

.submenu-item {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 0.125rem;
}

.submenu-item:hover,
.submenu-item.active {
  background-color: rgba(255, 255, 255, 0.15);
}

.submenu-item i,
.submenu-item iconify-icon {
  font-size: 1.1rem;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: all 0.3s ease;
}

.top-bar {
  height: 64px;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.content-body {
  padding: 2rem;
  flex: 1;
}

/* Components */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-size: 0.875rem;
  gap: 0.75rem;
  text-decoration: none;
}

.btn iconify-icon {
  font-size: 1.25rem;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success-color);
  color: white;
}
.btn-success:hover {
  filter: brightness(0.9);
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}
.btn-danger:hover {
  filter: brightness(0.9);
}

.btn-warning {
  background: var(--warning-color);
  color: white;
}
.btn-warning:hover {
  filter: brightness(0.9);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}
.btn-secondary:hover {
  filter: brightness(0.9);
}

.btn-info {
  background: var(--info-color);
  color: white;
}
.btn-info:hover {
  filter: brightness(0.9);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
}

.form-control {
  width: 100%;
  padding: 0.625rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Login Page */
.login-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-color);
  font-weight: 600;
  color: var(--text-muted);
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

tr:hover {
  background-color: #f1f5f9;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: -260px; /* Totalmente oculto por defecto */
    top: 0;
    bottom: 0;
    z-index: 1000;
    width: 260px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
    transition: left 0.3s ease;
  }

  /* Cuando el menú está ACTIVO en móvil/tablet */
  .sidebar-active .sidebar {
    left: 0;
  }

  .top-bar {
    padding: 0 1rem;
    position: sticky;
    top: 0;
  }

  .content-body {
    padding: 1rem;
  }

  /* Ajustes para el módulo de ventas en tablet */
  .sales-grid {
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto 1fr;
    display: flex !important;
    flex-direction: column;
    height: auto !important;
  }

  .panel-izquierdo {
    display: none !important; /* Ocultar panel de categorías lateral en tablet móvil */
  }

  .tablet-hide {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .sales-grid {
    grid-template-columns: 1fr !important;
  }

  .login-card {
    margin: 1rem;
  }
}
