:root {
  --primary: #6c3a9e;
  --primary-dark: #542a7a;
  --primary-light: #8b5cc7;
  --secondary: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --dark: #1e1b4b;
  --gray-50: #faf5ff;
  --gray-100: #f3e8ff;
  --gray-200: #e9d5ff;
  --gray-300: #d8b4fe;
  --gray-400: #c084fc;
  --gray-500: #a855f7;
  --gray-600: #9333ea;
  --gray-700: #7e22ce;
  --gray-800: #6b21a8;
  --gray-900: #4c1d95;
  --sidebar-width: 260px;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--gray-50);
  min-height: 100vh;
}

/* ===== LOGIN ===== */
.login-page {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: white;
  border-radius: 1.5rem;
  padding: 3rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
}

.login-card .logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-card .logo h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.login-card .logo p {
  color: var(--gray-500);
  font-size: 0.9rem;
}

.login-card .form-control {
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--gray-200);
  transition: all 0.2s;
}

.login-card .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 58, 158, 0.15);
}

.login-card .btn-primary {
  background: var(--primary);
  border: none;
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-weight: 600;
  transition: all 0.2s;
}

.login-card .btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--dark) 0%, var(--primary-dark) 100%);
  color: white;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar .sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar .sidebar-brand h4 {
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0;
}

.sidebar .sidebar-brand small {
  opacity: 0.7;
  font-size: 0.8rem;
}

.sidebar .nav-link {
  color: rgba(255, 255, 255, 0.7);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.sidebar .nav-link:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar .nav-link.active {
  color: white;
  background: rgba(255, 255, 255, 0.15);
  border-left-color: var(--secondary);
}

.sidebar .nav-link i {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
}

.sidebar .sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar .sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar .sidebar-footer .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--dark);
  overflow: hidden;
}

.sidebar .sidebar-footer .user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar .sidebar-footer .user-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.sidebar .sidebar-footer .user-role {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 0;
}

.page-header {
  background: white;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  margin: 0;
}

.page-body {
  padding: 1.5rem 2rem;
}

/* ===== CARDS ===== */
.card {
  border: none;
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: all 0.2s;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.card-header {
  background: white;
  border-bottom: 1px solid var(--gray-100);
  padding: 1rem 1.5rem;
  border-radius: 1rem 1rem 0 0 !important;
  font-weight: 600;
}

.stat-card {
  border-radius: 1rem;
  padding: 1.5rem;
  color: white;
  position: relative;
  overflow: hidden;
}

.stat-card .stat-icon {
  position: absolute;
  right: 1rem;
  top: 1rem;
  font-size: 2.5rem;
  opacity: 0.2;
}

.stat-card .stat-number {
  font-size: 2rem;
  font-weight: 700;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  opacity: 0.85;
}

.stat-card.purple { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.stat-card.gold { background: linear-gradient(135deg, var(--secondary), #d97706); }
.stat-card.green { background: linear-gradient(135deg, var(--success), #059669); }
.stat-card.blue { background: linear-gradient(135deg, var(--info), #2563eb); }
.stat-card.red { background: linear-gradient(135deg, var(--danger), #dc2626); }

/* ===== TABLES ===== */
.table-container {
  background: white;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.table {
  margin-bottom: 0;
}

.table thead th {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  color: var(--gray-700);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
}

.table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--gray-100);
}

/* ===== BADGES ===== */
.badge-estado {
  padding: 0.35em 0.75em;
  border-radius: 2rem;
  font-weight: 500;
  font-size: 0.75rem;
}

.badge-estado.PENDIENTE { background: #fef3c7; color: #92400e; }
.badge-estado.APROBADA { background: #dbeafe; color: #1e40af; }
.badge-estado.EN_PRODUCCION { background: #d1fae5; color: #065f46; }
.badge-estado.FACTURADA { background: #ede9fe; color: #5b21b6; }
.badge-estado.CANCELADA { background: #fce7f3; color: #9d174d; }
.badge-estado.DISPONIBLE { background: #d1fae5; color: #065f46; }
.badge-estado.PENDIENTE_REPOSICION { background: #fef3c7; color: #92400e; }

/* ===== FORMS ===== */
.form-label {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
}

.form-control, .form-select {
  border-radius: 0.75rem;
  border: 2px solid var(--gray-200);
  padding: 0.6rem 1rem;
  transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 58, 158, 0.15);
}

/* ===== BUTTONS ===== */
.btn {
  border-radius: 0.75rem;
  padding: 0.5rem 1.25rem;
  font-weight: 500;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

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

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

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

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

/* ===== MODAL ===== */
.modal-content {
  border: none;
  border-radius: 1.25rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
}

.modal-header {
  border-bottom: 1px solid var(--gray-100);
  padding: 1.25rem 1.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--gray-100);
  padding: 1rem 1.5rem;
}

/* ===== SIDEBAR TOGGLE (mobile) ===== */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--dark);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: block;
  }
  .page-body {
    padding: 1rem;
  }
  .page-header {
    padding: 1rem;
  }
}

/* ===== MISC ===== */
.alert-stock-bajo {
  border-left: 4px solid var(--danger);
}

.scrollable-table {
  max-height: 500px;
  overflow-y: auto;
}

.pointer { cursor: pointer; }

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

.search-box {
  position: relative;
}

.search-box .form-control {
  padding-left: 2.5rem;
}

.search-box i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}

/* ===== TIMELINE ===== */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.timeline-item {
  position: relative;
  padding-bottom: 1.5rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.5rem;
  top: 0.35rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
}

.timeline-item.completed::before {
  background: var(--success);
}

.timeline-item.pending::before {
  background: var(--gray-300);
}

/* ===== PRINT / PDF ===== */
@media print {
  .sidebar, .page-header, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 0 !important; }
}
