:root {
  --primary: #1e3a8a;
  --primary-hover: #1e40af;
  --secondary: #0f172a;
  --accent: #059669;
  --accent-hover: #047857;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;
  --bg-light: #f8fafc;
  --surface: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-light);
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 80px; /* Espacio para barra de navegación móvil */
}

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

/* Sidebar Desktop */
.sidebar {
  display: none;
  width: 260px;
  background-color: var(--secondary);
  color: #fff;
  flex-shrink: 0;
  padding: 24px 16px;
  flex-direction: column;
}

.sidebar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-link:hover, .sidebar-link.active {
  background-color: var(--primary);
  color: #ffffff;
}

/* Main Content */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Header */
.top-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switch {
  display: flex;
  gap: 6px;
  background: var(--bg-light);
  padding: 4px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.lang-btn {
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 16px;
  color: var(--text-muted);
  transition: all 0.2s;
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Contenido Principal */
.content-area {
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Barra de Navegación Inferior (Móvil) */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  gap: 4px;
  flex: 1;
  padding: 6px 0;
}

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

.nav-item svg {
  width: 22px;
  height: 22px;
}

/* Tarjetas y Componentes */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

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

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Botones de Acción Rápida (Estilo App Móvil) */
.quick-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  transition: transform 0.1s, box-shadow 0.2s;
}

.quick-btn:active {
  transform: scale(0.98);
}

.quick-btn-primary {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: #fff;
}

.quick-btn-accent {
  background: linear-gradient(135deg, #065f46 0%, #10b981 100%);
  color: #fff;
}

.quick-btn svg {
  width: 32px;
  height: 32px;
}

/* Badges de Estado */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }

/* Formularios */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: #fff;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
  width: 100%;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }

.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-danger { background: var(--danger); color: #fff; }

/* Contenedor de Cámara y Escaneo */
.camera-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0 auto 20px auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-overlay {
  position: absolute;
  top: 15%;
  left: 10%;
  right: 10%;
  bottom: 15%;
  border: 3px dashed rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* Área de Firma Táctil */
.signature-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fff;
  position: relative;
  width: 100%;
  height: 180px;
  margin-bottom: 10px;
  touch-action: none;
}

.signature-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Tablas Responsivas */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.table th, .table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg-light);
  font-weight: 600;
  color: var(--text-muted);
}

/* Media Queries para Pantallas Grandes (Desktop / Tablet) */
@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }
  .sidebar {
    display: flex;
  }
  .mobile-bottom-nav {
    display: none;
  }
  .quick-action-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .btn {
    width: auto;
  }
  .form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
  }
}
