/* ========================================
   SIDEBAR LAYOUT - Diseño moderno con menú lateral
   ======================================== */

:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 70px;
  --header-height: 64px;
  --primary: #ff6b35;
  --primary-dark: #e55a28;
  --accent: #1e3a5f;
  --bg-light: #f8f9fa;
  --bg-white: #ffffff;
  --text-dark: #2c3e50;
  --text-muted: #6c757d;
  --border-color: #e9ecef;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-light);
  color: var(--text-dark);
  overflow-x: hidden;
  font-size: 16px;
}

/* ========================================
   LAYOUT PRINCIPAL
   ======================================== */

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

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease, width 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-height);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--primary);
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand-title {
  font-weight: 800;
  font-size: 20px;
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-brand-sub {
  font-size: 13px;
  opacity: 0.8;
  white-space: nowrap;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
}

.sidebar-menu::-webkit-scrollbar {
  width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  border-left: 3px solid transparent;
  gap: 12px;
  font-size: 15px;
}

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

.menu-item.active {
  background: rgba(255,255,255,0.15);
  border-left-color: var(--accent);
  color: white;
  font-weight: 600;
}

.menu-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  font-weight: 600;
}

.menu-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  opacity: 0.8;
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.top-header {
  background: var(--bg-white);
  height: var(--header-height);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-dark);
  font-size: 24px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

.menu-toggle:hover {
  background: var(--bg-light);
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-light);
  color: var(--text-dark);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 18px;
}

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

.content-area {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ========================================
   SECCIÓN CAJA/POS - Diseño de 2 columnas
   ======================================== */

.pos-layout {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 20px;
  height: calc(100vh - 180px);
  overflow: hidden;
}

.pos-products-section {
  background: var(--bg-white);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pos-search-bar {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.pos-search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.pos-search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.pos-category-filter {
  min-width: 150px;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  cursor: pointer;
}

.pos-products-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  align-content: start;
}

.product-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  min-height: 240px;
  max-height: 280px;
}

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

.product-card-image {
  width: 100%;
  height: 80px;
  background: var(--bg-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--text-muted);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.product-card-inv {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--primary);
  color: white;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.product-card-name-badge {
  font-weight: 700;
  font-size: 14px;
  color: #2c3e50;
  line-height: 1.3;
  height: 36px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
  padding: 2px 4px;
  word-break: break-word;
  flex-shrink: 0;
}

.product-card-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dark);
  line-height: 1.3;
  min-height: 36px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card-price {
  font-size: 16px;
  font-weight: 700;
  color: #ff6b35;
  text-align: center;
  margin: 4px 0;
  flex-shrink: 0;
}

.product-card-stock {
  font-size: 11px;
  color: #6c757d;
  text-align: center;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.product-card-btn {
  width: 100%;
  padding: 10px;
  border: none;
  background: #ff6b35;
  color: white;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: auto;
}

.product-card-btn:hover {
  background: var(--primary-dark);
}

.product-card-btn:disabled {
  background: var(--border-color);
  cursor: not-allowed;
}

/* ========================================
   PANEL DE TICKET (Derecha)
   ======================================== */

.pos-ticket-panel {
  background: var(--bg-white);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ticket-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.ticket-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.ticket-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
  max-height: 350px;
}

.ticket-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-light);
  border-radius: 8px;
  position: relative;
}

.ticket-item-info {
  flex: 1;
  min-width: 0;
}

.ticket-item-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-item-price {
  font-size: 13px;
  color: var(--text-muted);
}

.ticket-item-quantity {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticket-item-qty-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: white;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
  transition: all 0.2s;
}

.ticket-item-qty-btn:hover {
  background: var(--primary);
  color: white;
}

.ticket-item-qty {
  min-width: 30px;
  text-align: center;
  font-weight: 600;
}

.ticket-item-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border: none;
  background: #dc3545;
  color: white;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ticket-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.ticket-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.ticket-summary {
  padding: 12px 16px;
  border-top: 2px solid var(--border-color);
  background: var(--bg-light);
}

.ticket-summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 15px;
}

.ticket-summary-row.total {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 2px solid var(--border-color);
}

.ticket-actions {
  padding: 12px 16px;
  display: flex;
  gap: 12px;
}

.btn-ticket-action {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear {
  background: white;
  border: 2px solid var(--border-color);
  color: var(--text-dark);
}

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

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

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

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1200px) {
  .pos-layout {
    grid-template-columns: 1fr 350px;
  }
  
  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
  }
}

@media (max-width: 992px) {
  :root {
    --sidebar-width: 70px;
  }
  
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }
  
  .sidebar-brand,
  .menu-text,
  .user-details {
    display: none;
  }
  
  .sidebar-header {
    justify-content: center;
  }
  
  .menu-item {
    justify-content: center;
    padding: 12px;
  }
  
  .user-info {
    justify-content: center;
  }
  
  .main-content {
    margin-left: var(--sidebar-collapsed-width);
  }
  
  .pos-layout {
    grid-template-columns: 1fr;
  }
  
  .pos-ticket-panel {
    position: fixed;
    right: -100%;
    top: 0;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    z-index: 1001;
    transition: right 0.3s ease;
  }
  
  .pos-ticket-panel.show {
    right: 0;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .menu-toggle {
    display: flex;
  }
  
  .page-title {
    font-size: 18px;
  }
  
  .content-area {
    padding: 16px;
  }
  
  .pos-search-bar {
    flex-direction: column;
  }
  
  .pos-search-input,
  .pos-category-filter {
    width: 100%;
  }
  
  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 16px;
  }
  
  .product-card {
    padding: 16px;
    min-height: 260px;
  }
}

/* ========================================
   UTILIDADES
   ======================================== */

.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
}

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

.mb-0 {
  margin-bottom: 0;
}

.mt-2 {
  margin-top: 8px;
}

.card {
  background: var(--bg-white);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.card h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
}
