/* ============================================
   DISEÑO RESPONSIVO PARA SISTEMA FONOAUDIOLOGÍA
   ============================================ */

/* Variables CSS para colores y espaciado */
:root {
  --primary-color: #2563eb;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --info-color: #06b6d4;
  --light-color: #f8fafc;
  --dark-color: #1e293b;

  --border-radius: 8px;
  --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;

  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
}

/* ============================================
   RESET Y CONFIGURACIÓN BASE
   ============================================ */

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

/* ============================================
   CONTENEDORES PRINCIPALES
   ============================================ */

.container-fluid {
  padding-left: var(--spacing-md);
  padding-right: var(--spacing-md);
  max-width: 100%;
}

.main-content {
  min-height: 100vh;
  padding: var(--spacing-md);
}

/* ============================================
   SISTEMA DE GRILLAS RESPONSIVO
   ============================================ */

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -var(--spacing-sm);
}

.col {
  flex: 1;
  padding: 0 var(--spacing-sm);
  min-width: 0;
}

.col-12 { width: 100%; }
.col-11 { width: 91.666667%; }
.col-10 { width: 83.333333%; }
.col-9 { width: 75%; }
.col-8 { width: 66.666667%; }
.col-7 { width: 58.333333%; }
.col-6 { width: 50%; }
.col-5 { width: 41.666667%; }
.col-4 { width: 33.333333%; }
.col-3 { width: 25%; }
.col-2 { width: 16.666667%; }
.col-1 { width: 8.333333%; }

/* ============================================
   FORMULARIOS RESPONSIVOS
   ============================================ */

.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: 600;
  color: var(--dark-color);
  font-size: var(--font-size-sm);
}

.form-control {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid #d1d5db;
  border-radius: var(--border-radius);
  font-size: var(--font-size-base);
  line-height: 1.5;
  transition: var(--transition);
  background-color: #fff;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control:disabled {
  background-color: #f3f4f6;
  opacity: 0.6;
  cursor: not-allowed;
}

/* Select mejorado */
.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  appearance: none;
}

/* Textarea mejorado */
.form-control.textarea {
  min-height: 100px;
  resize: vertical;
}

/* ============================================
   BOTONES RESPONSIVOS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm) var(--spacing-md);
  margin: var(--spacing-xs);
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  min-height: 38px;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: #1d4ed8;
  border-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: var(--box-shadow);
}

.btn-secondary {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
  color: white;
}

.btn-success {
  background-color: var(--success-color);
  border-color: var(--success-color);
  color: white;
}

.btn-warning {
  background-color: var(--warning-color);
  border-color: var(--warning-color);
  color: white;
}

.btn-danger {
  background-color: var(--danger-color);
  border-color: var(--danger-color);
  color: white;
}

.btn-outline-primary {
  background-color: transparent;
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-outline-primary:hover {
  background-color: var(--primary-color);
  color: white;
}

.btn-sm {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-sm);
  min-height: 32px;
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: var(--font-size-lg);
  min-height: 48px;
}

/* ============================================
   CARDS Y CONTENEDORES
   ============================================ */

.card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  overflow: hidden;
  transition: var(--transition);
  margin-bottom: var(--spacing-md);
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.card-header {
  padding: var(--spacing-md);
  background-color: var(--light-color);
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
}

.card-body {
  padding: var(--spacing-md);
}

.card-footer {
  padding: var(--spacing-md);
  background-color: var(--light-color);
  border-top: 1px solid #e5e7eb;
}

.card-title {
  margin: 0 0 var(--spacing-sm) 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--dark-color);
}

/* ============================================
   MODALES RESPONSIVOS
   ============================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  padding: var(--spacing-md);
}

.modal-dialog {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.modal-body {
  padding: var(--spacing-md);
}

.modal-footer {
  padding: var(--spacing-md);
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: var(--spacing-sm);
  justify-content: flex-end;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--secondary-color);
  padding: var(--spacing-xs);
}

/* ============================================
   TABLAS RESPONSIVAS
   ============================================ */

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  margin-bottom: var(--spacing-md);
  border-collapse: collapse;
}

.table th,
.table td {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  font-size: var(--font-size-sm);
}

.table th {
  background-color: var(--light-color);
  font-weight: 600;
  color: var(--dark-color);
  white-space: nowrap;
}

.table tbody tr:hover {
  background-color: #f9fafb;
}

/* ============================================
   ALERTAS Y NOTIFICACIONES
   ============================================ */

.alert {
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  position: relative;
}

.alert-success {
  background-color: #d1fae5;
  border-color: #a7f3d0;
  color: #065f46;
}

.alert-warning {
  background-color: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.alert-danger {
  background-color: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-info {
  background-color: #dbeafe;
  border-color: #bfdbfe;
  color: #1e40af;
}

/* ============================================
   UTILIDADES RESPONSIVAS
   ============================================ */

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }

.justify-content-start { justify-content: flex-start !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }

.align-items-start { align-items: flex-start !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }

.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }

.text-primary { color: var(--primary-color) !important; }
.text-secondary { color: var(--secondary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-danger { color: var(--danger-color) !important; }

.bg-primary { background-color: var(--primary-color) !important; }
.bg-light { background-color: var(--light-color) !important; }

.m-0 { margin: 0 !important; }
.mt-1 { margin-top: var(--spacing-xs) !important; }
.mb-1 { margin-bottom: var(--spacing-xs) !important; }
.mt-2 { margin-top: var(--spacing-sm) !important; }
.mb-2 { margin-bottom: var(--spacing-sm) !important; }
.mt-3 { margin-top: var(--spacing-md) !important; }
.mb-3 { margin-bottom: var(--spacing-md) !important; }
.mt-4 { margin-top: var(--spacing-lg) !important; }
.mb-4 { margin-bottom: var(--spacing-lg) !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: var(--spacing-xs) !important; }
.p-2 { padding: var(--spacing-sm) !important; }
.p-3 { padding: var(--spacing-md) !important; }
.p-4 { padding: var(--spacing-lg) !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Tablets (768px y arriba) */
@media (min-width: 768px) {
  .container-fluid {
    padding-left: var(--spacing-lg);
    padding-right: var(--spacing-lg);
  }

  .main-content {
    padding: var(--spacing-lg);
  }

  .modal-dialog {
    max-width: 600px;
  }

  .col-md-1 { width: 8.333333%; }
  .col-md-2 { width: 16.666667%; }
  .col-md-3 { width: 25%; }
  .col-md-4 { width: 33.333333%; }
  .col-md-5 { width: 41.666667%; }
  .col-md-6 { width: 50%; }
  .col-md-7 { width: 58.333333%; }
  .col-md-8 { width: 66.666667%; }
  .col-md-9 { width: 75%; }
  .col-md-10 { width: 83.333333%; }
  .col-md-11 { width: 91.666667%; }
  .col-md-12 { width: 100%; }

  .d-md-none { display: none !important; }
  .d-md-block { display: block !important; }
  .d-md-flex { display: flex !important; }
}

/* Desktop (1024px y arriba) */
@media (min-width: 1024px) {
  .container-fluid {
    max-width: 1200px;
    margin: 0 auto;
  }

  .modal-dialog {
    max-width: 800px;
  }

  .col-lg-1 { width: 8.333333%; }
  .col-lg-2 { width: 16.666667%; }
  .col-lg-3 { width: 25%; }
  .col-lg-4 { width: 33.333333%; }
  .col-lg-5 { width: 41.666667%; }
  .col-lg-6 { width: 50%; }
  .col-lg-7 { width: 58.333333%; }
  .col-lg-8 { width: 66.666667%; }
  .col-lg-9 { width: 75%; }
  .col-lg-10 { width: 83.333333%; }
  .col-lg-11 { width: 91.666667%; }
  .col-lg-12 { width: 100%; }

  .d-lg-none { display: none !important; }
  .d-lg-block { display: block !important; }
  .d-lg-flex { display: flex !important; }
}

/* ============================================
   RESPONSIVE PARA MÓVILES (max-width: 767px)
   ============================================ */

@media (max-width: 767px) {
  .container-fluid {
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
  }

  .main-content {
    padding: var(--spacing-sm);
  }

  /* Botones en móviles */
  .btn {
    width: 100%;
    margin-bottom: var(--spacing-sm);
    padding: var(--spacing-md);
    font-size: var(--font-size-base);
  }

  .btn-group-mobile {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .btn-group-mobile .btn {
    margin: 0;
  }

  /* Cards en móviles */
  .card {
    margin-bottom: var(--spacing-sm);
  }

  .card-header,
  .card-body,
  .card-footer {
    padding: var(--spacing-sm);
  }

  /* Formularios en móviles */
  .form-control {
    font-size: 16px; /* Prevenir zoom en iOS */
    padding: var(--spacing-md);
  }

  .form-label {
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-sm);
  }

  /* Modales en móviles */
  .modal {
    padding: var(--spacing-sm);
    align-items: flex-start;
    padding-top: var(--spacing-md);
  }

  .modal-dialog {
    width: 100%;
    margin: 0;
    max-height: calc(100vh - 2rem);
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--spacing-sm);
  }

  .modal-footer {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .modal-footer .btn {
    width: 100%;
    margin: 0;
  }

  /* Tablas en móviles */
  .table-responsive {
    border: 1px solid #e5e7eb;
    border-radius: var(--border-radius);
  }

  .table th,
  .table td {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-sm);
  }

  /* Ocultar columnas menos importantes en móviles */
  .table .d-none-mobile {
    display: none;
  }

  /* Hacer todas las columnas full-width en móviles */
  .col-mobile-12 {
    width: 100%;
  }

  /* Stack elementos horizontalmente en móviles */
  .row-mobile-stack {
    flex-direction: column;
  }

  .row-mobile-stack .col {
    width: 100%;
    margin-bottom: var(--spacing-sm);
  }

  /* Text alignment en móviles */
  .text-mobile-center {
    text-align: center !important;
  }

  /* Espaciado reducido en móviles */
  .p-mobile-sm {
    padding: var(--spacing-sm) !important;
  }

  .m-mobile-sm {
    margin: var(--spacing-sm) !important;
  }
}

/* ============================================
   ACCESIBILIDAD Y FOCUS
   ============================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible mejorado */
.form-control:focus,
.btn:focus,
.btn-close:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ============================================
   ANIMACIONES SUTILES
   ============================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-10px); }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-fade-out {
  animation: fadeOut 0.3s ease-out;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .btn,
  .modal,
  .alert {
    display: none !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid #000;
  }

  .table th,
  .table td {
    border: 1px solid #000;
  }
}
