/* Modo oscuro - accesible */
:root {
  --primary: #E63950;
  --primary-dark: #B82E3F;
  --primary-light: #FF6B7D;
  --secondary: #4ECB71;
  --accent: #F5A623;
  --bg: #0f0f12;
  --surface: #1a1a1f;
  --surface-hover: #25252c;
  --surface-elevated: #2a2a33;
  --text: #f0f0f5;
  --text-secondary: #b8b8c8;
  --text-muted: #8888a0;
  --border: #333344;
  --danger: #ff5c5c;
  --warning: #ffd166;
  --success: #6eeb8f;
  --info: #72ddf7;
  --sidebar-width: 280px;
}

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

html {
  font-size: 16px;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Tipografía accesible */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 600;
}

p, span, label, input, select, textarea, button, td, th {
  font-size: 1.05rem;
}

/* Login */
.login-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  padding: 40px 32px;
  border-radius: 20px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo i {
  font-size: 56px;
  color: var(--primary);
}

.login-logo h1 {
  font-size: 2rem;
  margin-top: 16px;
  color: var(--text);
}

.login-logo p {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.login-logo-img {
  width: 120px;
  height: auto;
  margin-bottom: 12px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 1.1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230, 57, 80, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.error-message {
  color: var(--danger);
  font-size: 1rem;
  margin-top: 12px;
  text-align: center;
  font-weight: 500;
}

/* Buttons - grandes y accesibles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 22px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.05rem;
  text-decoration: none;
  min-height: 48px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--secondary);
  color: #0a0a0a;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-light);
}

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

.btn-warning {
  background: var(--warning);
  color: #1a1a1a;
}

.btn-success {
  background: var(--success);
  color: #0a0a0a;
}

.btn-sm {
  padding: 10px 14px;
  font-size: 0.95rem;
  min-height: 40px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-icon:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--primary-light);
}

/* Layout */
.main-app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 100;
  transition: transform 0.3s;
  border-right: 1px solid var(--border);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 1.35rem;
  font-weight: 700;
}

.sidebar-header i {
  color: var(--primary);
  font-size: 1.6rem;
}

.sidebar-logo-img {
  width: 40px;
  height: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 14px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 14px;
  margin-bottom: 6px;
  transition: all 0.2s;
  font-weight: 500;
  font-size: 1.05rem;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(230, 57, 80, 0.15);
  color: var(--text);
}

.nav-item.active {
  border-left: 4px solid var(--primary);
}

.nav-item i {
  width: 26px;
  text-align: center;
  font-size: 1.2rem;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border);
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.sync-status.offline {
  color: var(--warning);
}

.user-info {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

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

.topbar {
  background: var(--surface);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
}

.menu-toggle {
  display: none;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  align-items: center;
  justify-content: center;
}

.topbar h2 {
  flex: 1;
  font-size: 1.6rem;
  color: var(--text);
}

.page-content {
  padding: 28px;
  flex: 1;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-size: 1.3rem;
  color: var(--text);
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  transition: transform 0.2s;
  cursor: pointer;
}

.stat-card:hover,
.stat-card:focus {
  transform: translateY(-2px);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.stat-card i {
  font-size: 32px;
  color: var(--primary);
  margin-bottom: 14px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
}

th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.9rem;
  background: var(--surface-elevated);
}

tr:hover {
  background: var(--surface-hover);
}

.badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 600;
}

.badge-pendiente {
  background: rgba(245, 166, 35, 0.2);
  color: var(--warning);
}

.badge-confirmado {
  background: rgba(110, 235, 143, 0.15);
  color: var(--success);
}

.badge-rechazado {
  background: rgba(255, 92, 92, 0.15);
  color: var(--danger);
}

/* Lists */
.list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.item-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  transition: transform 0.2s;
}

.item-card:hover {
  transform: translateY(-2px);
}

.item-card h3 {
  font-size: 1.25rem;
  margin-bottom: 12px;
  color: var(--text);
}

.item-card p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.item-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* Forms */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.form-actions {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* Search */
.search-bar {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-bar input,
.search-bar select {
  flex: 1;
  min-width: 220px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 1.1rem;
}

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

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 20px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.4rem;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
  width: 44px;
  height: 44px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 18px 24px;
  border-radius: 14px;
  color: white;
  font-weight: 600;
  z-index: 300;
  transform: translateY(120px);
  opacity: 0;
  transition: all 0.3s;
  max-width: 420px;
  font-size: 1.05rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { background: var(--success); color: #0a0a0a; }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #0a0a0a; }
.toast.info { background: var(--info); color: #0a0a0a; }

/* Loading */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 18, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
}

.spinner {
  width: 56px;
  height: 56px;
  border: 5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pagination */
.pagination {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 24px;
}

.pagination button {
  padding: 12px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Mobile - letras grandes y accesible */
@media (max-width: 768px) {
  html {
    font-size: 18px;
  }

  body {
    font-size: 1.1rem;
  }

  p, span, label, input, select, textarea, button, td, th {
    font-size: 1.1rem;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 85%;
    max-width: 320px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
  }

  .topbar {
    padding: 16px;
  }

  .topbar h2 {
    font-size: 1.4rem;
  }

  .page-content {
    padding: 18px;
  }

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

  .stat-value {
    font-size: 2.2rem;
  }

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

  .item-card {
    padding: 20px;
  }

  .item-card h3 {
    font-size: 1.3rem;
  }

  .btn {
    min-height: 52px;
    padding: 16px 20px;
    font-size: 1.1rem;
  }

  .btn-sm {
    min-height: 46px;
    font-size: 1rem;
  }

  .btn-icon {
    width: 52px;
    height: 52px;
  }

  .search-bar input,
  .search-bar select,
  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 16px;
    font-size: 1.15rem;
  }

  .form-group label {
    font-size: 1.05rem;
  }

  th, td {
    padding: 16px;
    font-size: 1.05rem;
  }

  .nav-item {
    padding: 18px 20px;
    font-size: 1.15rem;
  }

  .login-card {
    padding: 32px 24px;
  }

  .login-logo h1 {
    font-size: 2.2rem;
  }

  .modal {
    max-height: 95vh;
    border-radius: 18px;
  }

  .modal-header h3 {
    font-size: 1.45rem;
  }

  .modal-body {
    padding: 20px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .item-actions {
    flex-direction: column;
  }

  .item-actions .btn {
    width: 100%;
  }
}

/* Tablets */
@media (min-width: 769px) and (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .list-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Focus visible para accesibilidad */
*:focus-visible {
  outline: 3px solid var(--primary-light);
  outline-offset: 2px;
}

/* Reducir movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Estilos de impresión */
@media print {
  .sidebar,
  .topbar,
  .search-bar,
  .item-actions,
  .btn,
  #syncStatus,
  #userInfo,
  #logoutBtn,
  .modal-overlay,
  .fab {
    display: none !important;
  }

  .content {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }

  table {
    width: 100%;
    border-collapse: collapse;
  }

  th, td {
    border: 1px solid #999;
    padding: 6px;
  }
}
