:root {
  --glass-bg: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(0, 0, 0, 0.05);
  --glass-blur: 12px;
  --glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.1);
  
  --primary: #f0501e; /* CGA Laser Orange */
  --primary-glow: rgba(240, 80, 30, 0.15);
  --secondary: #64748b;
  --accent: #f97316;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --bg-main: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --text-main: #0f172a;
  --text-dim: #64748b;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(240, 80, 30, 0.05) 0, transparent 50%),
    radial-gradient(at 100% 100%, rgba(100, 116, 139, 0.05) 0, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
}

body.modal-open {
  overflow: hidden;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 5%;
  border-bottom: 1px solid var(--glass-border);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.85); /* Legibilidad asegurada */
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo { font-size: 1.5rem; }
.brand-name { font-weight: 800; letter-spacing: 1px; color: var(--text-main); }

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-item {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  transition: color 0.3s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-item:hover, .nav-item.active {
  color: var(--text-main);
}

/* Container */
.container {
  max-width: 1400px;
  margin: 6rem auto 2rem auto; /* Ajuste para navbar fija */
  padding: 0 2rem;
}

/* Hero Card */
.hero-card {
  padding: 2rem;
  border-radius: 20px;
  margin-bottom: 2rem;
}

.hero-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.hero-logo {
  width: 60px;
  height: 60px;
  background: var(--primary);
  border-radius: 4px; /* Square like CGA Logo */
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.5rem;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.hero-logo::after {
  content: '';
  position: absolute;
  width: 150%;
  height: 2px;
  background: rgba(255, 255, 255, 0.8);
  transform: rotate(-45deg); /* Simulating the laser beam */
  top: 50%;
  left: -25%;
}

.hero-text h2 { font-size: 2.2rem; margin-bottom: 0.25rem; }
.hero-text p { color: var(--text-dim); font-size: 1rem; }

.hero-actions {
  display: flex;
  gap: 1rem;
  flex: 1;
  max-width: 700px;
  justify-content: flex-end;
}

.search-wrapper {
  position: relative;
  flex: 1;
}

.search-wrapper input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 3rem;
  background: white;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text-main);
  outline: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.btn-primary {
  background: linear-gradient(to right, var(--primary), #d97706);
  border: none;
  padding: 0.85rem 1.5rem;
  border-radius: 10px;
  color: white;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-secondary {
  background: white;
  border: 1px solid #e2e8f0;
  padding: 0.85rem 1.5rem;
  border-radius: 10px;
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
}

.panel-header h3 {
  font-size: 1.1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-bar {
  display: flex;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.4);
  padding: 0.25rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-btn {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-main);
}

.filter-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* Sidebar */
.admin-sidebar {
  display: flex;
  flex-direction: column;
}

.admin-sidebar h4 {
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 1rem;
}

.admin-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-item {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 600;
  transition: all 0.3s ease;
}

.admin-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  transform: translateX(5px);
}

.admin-icon {
  font-size: 1.5rem;
  opacity: 1;
}

/* Orders Grid */
.orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.order-card {
  padding: 1.5rem;
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  transition: all 0.3s ease;
  cursor: pointer;
}

.order-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.order-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.order-client {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #1e40af; /* Deep Blue Unified */
  letter-spacing: 0.5px;
}

.status-badge, .status-tag {
  padding: 0.35rem 0.8rem;
  border-radius: 99px; /* Pill style */
  font-size: 0.65rem;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.order-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed #e2e8f0;
}

.order-deadline, .order-balance {
  display: flex;
  flex-direction: column;
}

.order-balance {
  text-align: right;
  align-items: flex-end;
}

.order-balance span {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text-main);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 5rem;
  text-align: center;
  color: var(--text-dim);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.8rem 1.5rem;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  color: white;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid rgba(255,255,255,0.1);
}

.toast-container.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* --- Modales y Estados Globales --- */
.modal { 
  display: none; 
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%; 
  background: rgba(0,0,0,0.5); 
  backdrop-filter: blur(4px); 
  z-index: 1000; 
  overflow-y: auto; 
  padding: 2rem 1rem;
}
.modal.active { display: block; }
.modal-content { 
  background: white; 
  padding: 2rem; 
  border-radius: 16px; 
  width: 100%; 
  max-width: 800px; 
  margin: 0 auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2); 
  position: relative;
}

.status-presupuesto { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.status-pendiente { background: #fff7ed; color: #c2410c; border-color: #fdba74; box-shadow: 0 1px 2px rgba(194, 65, 12, 0.05); }
.status-pendiente::before { content: "⏳"; font-size: 0.6rem; }

.status-en-produccion { 
    background: #eff6ff; 
    color: #1e40af; 
    border-color: #93c5fd; 
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.1); 
    position: relative;
    overflow: hidden;
}
.status-en-produccion::before { content: "⚙️"; font-size: 0.6rem; }

.status-en-produccion::after {
    content: "";
    position: absolute;
    top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shine 3s infinite;
}
.status-listo { 
    background: #ecfdf5; 
    color: #059669; 
    border-color: #6ee7b7; 
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.15); 
    animation: pulse-ready 2s infinite;
}
.status-listo::before { content: "✨"; font-size: 0.6rem; }

.status-entregado { 
    background: var(--text-main); 
    color: #ffffff; 
    border-color: #0f172a; 
    box-shadow: 0 4px 8px rgba(15, 23, 42, 0.2); 
    padding: 0.4rem 1rem;
    font-size: 0.7rem;
}
.status-entregado::before { content: "✅"; font-size: 0.7rem; }
.status-cancelado, .status-historico { 
    background: #f1f5f9; 
    color: #94a3b8; 
    border-color: #e2e8f0; 
    opacity: 0.6; 
}

@keyframes shine {
    0% { left: -100%; }
    20% { left: 100%; }
    100% { left: 100%; }
}

@keyframes pulse-ready {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.5rem; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-dim); }
.form-group input, .form-group select, .form-group textarea { padding: 0.75rem; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 0.9rem; outline: none; transition: border-color 0.2s; background: white; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }

/* --- Responsive Fixes --- */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

@media (max-width: 768px) {
  .navbar {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }

  .nav-links {
    gap: 1rem;
    font-size: 0.85rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .container {
    padding: 0 1rem;
    margin: 1rem auto;
  }

  .hero-content {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 1.5rem;
  }

  .hero-brand {
    justify-content: center;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    max-width: 100%;
  }

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

  .order-card {
    padding: 1rem;
  }

  .modal-content {
    padding: 1.5rem 1rem;
    border-radius: 12px;
    width: 95%;
  }

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

  /* Items editor on mobile */
  .item-row {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
    background: #f8fafc;
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    margin-bottom: 0.5rem;
    position: relative;
  }

  .item-subtotal {
    text-align: left !important;
    font-weight: 800;
  }

  .btn-remove-item {
    position: absolute;
    top: 5px;
    right: 5px;
    background: white !important;
    border: 1px solid #fee2e2 !important;
    border-radius: 50%;
    width: 25px;
    height: 25px;
  }

  .admin-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .admin-item {
    padding: 1rem;
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
    font-size: 0.9rem;
  }

  .panel-header {
    text-align: center;
    flex-direction: column !important;
    align-items: center !important;
    gap: 1rem;
  }

  .filter-bar {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Hide scrollbar Firefox */
  }
  .filter-bar::-webkit-scrollbar { display: none; } /* Hide scrollbar Chrome/Safari */

  .filter-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }
  
  /* Details Modal Adjustments */
  #detailHeader {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .hero-text h2 {
    font-size: 1.6rem;
  }
  
  .order-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .order-header .status-badge {
    align-self: flex-start;
  }
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 1rem;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.3);
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.9rem;
  color: var(--text-main);
}

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

.data-table tr {
  transition: background 0.2s;
}

.data-table tr:hover {
  background: rgba(240, 80, 30, 0.03);
}

.dashboard-table td {
  padding: 0.85rem 1rem;
}

.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

.sortable:hover {
  color: var(--primary);
}

.sort-icon::after {
  content: '↕️';
  font-size: 0.8rem;
  margin-left: 5px;
  opacity: 0.3;
}

th.sort-asc .sort-icon::after {
  content: '↑';
  opacity: 1;
  color: var(--primary);
}

th.sort-desc .sort-icon::after {
  content: '↓';
  opacity: 1;
  color: var(--primary);
}

.btn-action-small {
  padding: 0.4rem;
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action-small:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: scale(1.1);
}

/* Modal Actions Organization */
.action-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.action-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-dim);
    letter-spacing: 1.5px;
    margin-bottom: 0.25rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #f1f5f9;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-buttons.vertical {
    gap: 0.75rem;
}

.action-buttons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.5rem;
}

.action-buttons-grid .btn-secondary {
    padding: 0.8rem 0.5rem;
    font-size: 0.8rem;
}

@media (max-width: 600px) {
    .modal-actions-container > div {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
  .dashboard-table th:nth-child(3), 
  .dashboard-table td:nth-child(3),
  .dashboard-table th:nth-child(5),
  .dashboard-table td:nth-child(5) {
    display: none;
  }
}

@media (max-width: 900px) {
  .nav-custom-text {
    display: none;
  }
}
