/* ─────────────────────────────────────────────
   Design System — inventarioV2
   ───────────────────────────────────────────── */

:root {
  /* Primary palette */
  --primary: #009EE0;
  --primary-dark: #007BB0;
  --primary-light: #4DC2EB;
  --primary-subtle: #E5F5FC;

  /* Accent */
  --accent: #EE7F00;
  --accent-light: #F4A64D;

  /* Neutrals */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #333333;
  --gray-800: #1a1a1a;
  --gray-900: #000000;

  /* Status */
  --success: #009036;
  --warning: #EE7F00;
  --danger: #dc2626;

  /* Surfaces */
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --background: var(--gray-50);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─────────────────────────────────────────────
   Base
   ───────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--gray-800);
  line-height: 1.6;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────────────────────────
   App Layout (Sidebar + Mobile Nav)
   ───────────────────────────────────────────── */

.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.app-sidebar {
  width: 260px;
  background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1030;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-lg);
}

.app-sidebar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  padding: 1.5rem;
  letter-spacing: -0.02em;
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-sidebar-brand:hover {
  color: white;
}

.app-sidebar-nav {
  padding: 1rem 0;
  flex-grow: 1;
}

.app-sidebar-nav .nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  color: rgba(255, 255, 255, 0.75);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

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

.app-sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Mobile Navigation */
.mobile-topbar {
  display: none;
  background: var(--surface);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: var(--shadow-sm);
}

.mobile-topbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--surface);
  border-top: 1px solid var(--gray-200);
  z-index: 1030;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  padding-bottom: env(safe-area-inset-bottom); /* iOS safe area */
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.mobile-nav-item i {
  font-size: 1.25rem;
  margin-bottom: 0.1rem;
}

.mobile-nav-item:hover, .mobile-nav-item.active {
  color: var(--primary);
}

/* ─────────────────────────────────────────────
   Page Layout
   ───────────────────────────────────────────── */

.page-container {
  padding: 1.5rem;
  flex-grow: 1;
}

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

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.03em;
  margin: 0;
}

/* ─────────────────────────────────────────────
   Cards
   ───────────────────────────────────────────── */

.card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  transition: box-shadow var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  padding: 0.875rem 1.25rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─────────────────────────────────────────────
   Tables
   ───────────────────────────────────────────── */

.table {
  margin-bottom: 0;
  font-size: 0.875rem;
}

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

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

.table tbody tr {
  transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
  background-color: var(--primary-subtle);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(0, 0, 0, 0.015);
}

/* ─────────────────────────────────────────────
   Buttons
   ───────────────────────────────────────────── */

.btn {
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  letter-spacing: 0.01em;
}

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

.btn-primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 158, 224, 0.4);
}

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

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}

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

.btn-sm {
  font-size: 0.8125rem;
  padding: 0.3rem 0.6rem;
}

.btn-google {
  background-color: transparent;
  color: var(--gray-800);
  border: 1px solid var(--gray-300);
}

.btn-google:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--gray-900);
}

/* ─────────────────────────────────────────────
   Badges & Status
   ───────────────────────────────────────────── */

.badge {
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  padding: 0.3em 0.65em;
  border-radius: 9999px;
}

.stock-critical {
  background-color: #fef2f2 !important;
}

.stock-warning {
  background-color: #fffbeb !important;
}

.ip-link {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--primary);
  text-decoration: none;
}

.ip-link:hover {
  text-decoration: underline;
}

/* ─────────────────────────────────────────────
   Sort Header
   ───────────────────────────────────────────── */

.sort-link {
  text-decoration: none !important;
  color: var(--gray-600) !important;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.sort-link:hover {
  color: var(--primary) !important;
}

/* ─────────────────────────────────────────────
   Forms
   ───────────────────────────────────────────── */

.form-container {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--primary-subtle) 100%);
}

.form-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 32rem;
}

.form-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-300);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--gray-700);
  margin-bottom: 0.25rem;
}

.errorlist {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
  color: var(--danger);
  font-size: 0.75rem;
}

.help-text, .helptext {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

/* ─────────────────────────────────────────────
   Login Page
   ───────────────────────────────────────────── */

.login-wrapper {
  background-color: var(--background);
  position: relative;
  z-index: 1;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 35%, transparent 60%);
  z-index: -1;
  pointer-events: none;
}

@media (max-width: 768px) {
  .login-wrapper::before {
    background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 20%, transparent 45%);
  }
}

#left-panel {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
}

#left-panel h3 {
  font-weight: 600;
  margin-top: 1rem;
  color: white;
  letter-spacing: -0.01em;
}

#right-panel {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─────────────────────────────────────────────
   Diary
   ───────────────────────────────────────────── */

.diary-container {
  padding: 1.5rem;
}

.entry-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
  background: var(--surface);
}

.entry-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.highlight-entry {
  animation: highlight-pulse 2s ease;
}

@keyframes highlight-pulse {
  0%   { box-shadow: 0 0 0 rgba(0, 158, 224, 0); }
  50%  { box-shadow: 0 0 20px rgba(0, 158, 224, 0.3); }
  100% { box-shadow: 0 0 0 rgba(0, 158, 224, 0); }
}

/* ─────────────────────────────────────────────
   Modals
   ───────────────────────────────────────────── */

.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

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

.modal-body {
  padding: 1.5rem;
}

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

/* ─────────────────────────────────────────────
   Pagination
   ───────────────────────────────────────────── */

.pagination .page-link {
  border-radius: var(--radius-sm);
  margin: 0 0.15rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  transition: all var(--transition-fast);
}

.pagination .page-link:hover {
  background-color: var(--primary-subtle);
  border-color: var(--primary-light);
  color: var(--primary);
}

.pagination .page-item.active .page-link {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* ─────────────────────────────────────────────
   Toasts
   ───────────────────────────────────────────── */

.toast {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: none;
  font-size: 0.875rem;
}

/* ─────────────────────────────────────────────
   Animations
   ───────────────────────────────────────────── */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.4s ease forwards;
}

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }

/* ─────────────────────────────────────────────
   Printer Status Indicator
   ───────────────────────────────────────────── */

.printer-status-indicator .badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.ip-cell-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────
   Delete Confirmation
   ───────────────────────────────────────────── */

.delete-confirmation {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--background);
  padding: 1rem;
}

.delete-card {
  background-color: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 28rem;
}

.delete-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--gray-900);
}

.delete-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.delete-question {
  font-size: 1rem;
  color: var(--gray-600);
  text-align: center;
}

.delete-item-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

.delete-item-category {
  font-size: 0.875rem;
  color: var(--gray-500);
  text-align: center;
}

.delete-warning {
  display: flex;
  background-color: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1rem;
}

.warning-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: #d97706;
  flex-shrink: 0;
}

.warning-text {
  margin-left: 0.75rem;
}

.warning-text h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #92400e;
  margin: 0;
}

.warning-text p {
  font-size: 0.875rem;
  color: #92400e;
  margin: 0.25rem 0 0 0;
}

.delete-form {
  margin-top: 1.5rem;
}

.delete-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background-color: var(--danger);
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.625rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.delete-button:hover {
  background-color: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

.delete-icon {
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.5rem;
}

.cancel-link {
  display: block;
  text-align: center;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: 1rem;
  text-decoration: none;
}

.cancel-link:hover {
  text-decoration: underline;
}

/* ─────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────── */

@media (max-width: 768px) {
  .page-container {
    padding: 1rem;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .table {
    font-size: 0.8125rem;
  }
}

/* ─────────────────────────────────────────────
   Utility
   ───────────────────────────────────────────── */

.text-mono {
  font-family: var(--font-mono);
}

.gap-xs { gap: 0.25rem; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────
   Dark Mode Overrides
   ───────────────────────────────────────────── */

[data-bs-theme="dark"] {
  /* Override custom vars for dark mode */
  --background: #121212;
  --surface: #1e1e1e;
  --surface-elevated: #2d2d2d;
  
  --gray-50: #1a1a1a;
  --gray-100: #262626;
  --gray-200: #333333;
  --gray-300: #404040;
  --gray-600: #a3a3a3;
  --gray-700: #d4d4d4;
  --gray-800: #e5e5e5;
  --gray-900: #f5f5f5;
  
  --primary-subtle: rgba(0, 158, 224, 0.15);
}

[data-bs-theme="dark"] .app-sidebar {
  background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
  border-right-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .app-sidebar-nav .nav-link {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
}

[data-bs-theme="dark"] .form-container {
  background: linear-gradient(135deg, #121212 0%, #1a1a1a 100%);
}

[data-bs-theme="dark"] .delete-warning {
  background-color: #2b1f10;
  border-color: #78350f;
}

[data-bs-theme="dark"] .warning-text h3,
[data-bs-theme="dark"] .warning-text p,
[data-bs-theme="dark"] .warning-icon {
  color: #fbbf24;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: var(--surface-elevated);
  color: var(--gray-800);
  border-color: var(--gray-300);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--surface-elevated);
  color: var(--gray-900);
}

[data-bs-theme="dark"] .input-group-text {
  background-color: var(--surface-elevated);
  color: var(--gray-800);
  border-color: var(--gray-300);
}

[data-bs-theme="dark"] .btn-google:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .mobile-topbar,
[data-bs-theme="dark"] .mobile-bottom-nav {
  background-color: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .mobile-topbar-brand {
  color: var(--gray-900);
}

/* ─────────────────────────────────────────────
   Responsive App Layout Overrides
   ───────────────────────────────────────────── */

@media (max-width: 991.98px) {
  .app-sidebar {
    display: none !important;
  }
  .app-wrapper {
    flex-direction: column;
  }
  .mobile-topbar {
    display: flex;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .page-container {
    padding-bottom: 70px; /* Space for bottom nav */
  }
}

[data-bs-theme="dark"] .bg-white {
  background-color: var(--surface) !important;
  color: var(--gray-800) !important;
}

[data-bs-theme="dark"] .bg-light {
  background-color: var(--surface-elevated) !important;
}

[data-bs-theme="dark"] .card-header {
  border-bottom-color: var(--gray-200);
  background-color: var(--surface);
}

[data-bs-theme="dark"] .card-footer {
  border-top-color: var(--gray-200);
  background-color: var(--surface);
}
