/* Mobile First CSS - Sistema de Gestión de Empleados */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #f8f9fa;
  color: #343a40;
  line-height: 1.5;
  font-size: 16px;
}

/* Container - Mobile First */
.container {
  width: 100%;
  padding: 10px;
  max-width: none;
}

/* Header - Mobile Optimized */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 15px;
  text-align: center;
  margin-bottom: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
  font-size: 1.8rem;
  margin-bottom: 5px;
  font-weight: 700;
}

.header p {
  font-size: 0.9rem;
  opacity: 0.9;
  margin: 0;
}

/* Tabs - Mobile First */
.tabs {
  display: flex;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 15px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 1;
  min-width: 120px;
  padding: 12px 8px;
  background: #f8f9fa;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  border-radius: 8px;
  white-space: nowrap;
  text-align: center;
}

.tab.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  transform: translateY(-1px);
}

.tab:hover:not(.active) {
  background: #e9ecef;
}

/* Tab Content */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
  display: block;
}

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

/* Form Section - Mobile First */
.form-section {
  background: white;
  padding: 20px 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 15px;
}

.form-section h2,
.form-section h3 {
  color: #667eea;
  margin-bottom: 15px;
  font-size: 1.3rem;
  font-weight: 600;
}

/* Form Grid - Mobile First (Single Column) */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-weight: 600;
  margin-bottom: 8px;
  color: #495057;
  font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 12px 15px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 16px; /* Evita zoom en iOS */
  transition: all 0.3s ease;
  background-color: white;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
}

.form-group select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23666' d='m2 0-2 2h4zm0 5 2-2h-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 12px;
  padding-right: 45px;
}

/* Checkbox Group - Mobile Optimized */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin: 20px 0;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.checkbox-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #667eea;
  cursor: pointer;
}

.checkbox-item label {
  margin: 0;
  cursor: pointer;
  flex: 1;
  font-weight: 500;
}

/* Buttons - Mobile First */
.btn {
  padding: 14px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  min-height: 48px; /* Touch target size */
  width: 100%;
  margin-bottom: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-success {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: white;
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

.btn-warning {
  background: linear-gradient(135deg, #ffc107 0%, #ffcd39 100%);
  color: #212529;
}

.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 14px;
  min-height: 36px;
  width: auto;
  margin: 2px;
}

/* Table Section - Mobile First */
.table-section {
  background: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 15px;
}

.table-section h2,
.table-section h3 {
  color: #667eea;
  margin-bottom: 15px;
  font-size: 1.3rem;
  font-weight: 600;
}

/* Table Controls - Mobile First */
.table-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.search-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-filters input {
  padding: 12px 15px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 16px;
  width: 100%;
}

.search-filters input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.export-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Table - Mobile Optimized */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  background: white;
}

table {
  width: 100%;
  min-width: 700px; /* Minimum width for horizontal scroll */
  border-collapse: collapse;
  background: white;
  font-size: 14px;
}

thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

th,
td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid #e9ecef;
  white-space: nowrap;
}

th {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tbody tr:hover {
  background-color: #f8f9fa;
}

tbody tr:nth-child(even) {
  background-color: #fdfdfd;
}

/* Mobile Table Alternative - Card View */
.mobile-card-view {
  display: none;
}

.record-card {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.record-card h4 {
  color: #667eea;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 600;
}

.record-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f1f3f4;
}

.record-field:last-child {
  border-bottom: none;
}

.record-field strong {
  color: #495057;
  font-size: 14px;
  min-width: 100px;
}

.record-field span {
  color: #6c757d;
  font-size: 14px;
  text-align: right;
}

.record-actions {
  display: flex;
  gap: 8px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #f1f3f4;
}

.record-actions .btn-sm {
  flex: 1;
  margin: 0;
}

/* Badges */
.badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: #d4edda;
  color: #155724;
}

.badge-danger {
  background: #f8d7da;
  color: #721c24;
}

/* Alerts - Mobile Optimized */
.alert {
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-weight: 500;
  border-left: 4px solid;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border-left-color: #28a745;
}

.alert-danger {
  background: #f8d7da;
  color: #721c24;
  border-left-color: #dc3545;
}

.alert-warning {
  background: #fff3cd;
  color: #856404;
  border-left-color: #ffc107;
}

/* Modal - Mobile First */
.modal,
.export-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 20px;
  overflow-y: auto;
}

.modal-content,
.export-modal-content {
  background-color: white;
  margin: 20px auto;
  padding: 20px;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e9ecef;
}

.modal-header h2 {
  margin: 0;
  color: #667eea;
  font-size: 1.4rem;
}

.close {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close:hover {
  color: #667eea;
}

/* Export Options - Mobile Optimized */
.export-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}

.export-option {
  padding: 15px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: white;
}

.export-option:hover {
  border-color: #667eea;
  background: #f8f9ff;
}

.export-option.selected {
  border-color: #667eea;
  background: #f0f4ff;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.export-option h4 {
  margin: 0 0 5px 0;
  color: #495057;
  font-size: 16px;
}

.export-option p {
  margin: 0;
  color: #6c757d;
  font-size: 14px;
}

.export-filters {
  display: none;
  margin-top: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.export-filters.show {
  display: block;
}

.export-filters label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #495057;
}

.export-filters select,
.export-filters input {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 15px;
}

.export-filters select:focus,
.export-filters input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Loading */
.loading {
  display: none;
  text-align: center;
  padding: 30px 20px;
  background: white;
  border-radius: 8px;
  margin: 15px 0;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.mb-10 {
  margin-bottom: 10px;
}

.mt-10 {
  margin-top: 10px;
}

.hidden {
  display: none !important;
}

.show {
  display: block !important;
}

/* Tablet Styles - 768px and up */
@media (min-width: 768px) {
  .container {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
  }

  .header {
    padding: 30px;
    margin-bottom: 30px;
  }

  .header h1 {
    font-size: 2.2rem;
    margin-bottom: 10px;
  }

  .header p {
    font-size: 1.1rem;
  }

  .tabs {
    margin-bottom: 20px;
  }

  .tab {
    padding: 15px 20px;
    font-size: 16px;
    min-width: 150px;
  }

  .form-section,
  .table-section {
    padding: 25px;
    margin-bottom: 25px;
  }

  /* Form Grid - Two Columns on Tablet */
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  /* Checkbox Group - Horizontal on Tablet */
  .checkbox-group {
    flex-direction: row;
    gap: 20px;
  }

  .checkbox-item {
    flex: 1;
    max-width: 250px;
  }

  /* Table Controls - Horizontal */
  .table-controls {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }

  .search-filters {
    flex-direction: row;
    gap: 15px;
    flex: 1;
    max-width: 500px;
  }

  .export-buttons {
    flex-direction: row;
    gap: 10px;
    flex-shrink: 0;
  }

  .export-buttons .btn {
    width: auto;
    margin-bottom: 0;
  }

  /* Buttons - Inline on Tablet */
  .btn {
    width: auto;
    margin-bottom: 0;
    margin-right: 10px;
  }

  .btn:last-child {
    margin-right: 0;
  }

  /* Modal */
  .modal-content,
  .export-modal-content {
    margin: 40px auto;
    padding: 30px;
    max-width: 600px;
  }

  table {
    font-size: 15px;
  }

  th,
  td {
    padding: 15px 12px;
  }
}

/* Desktop Styles - 1024px and up */
@media (min-width: 1024px) {
  .container {
    max-width: 1400px;
    padding: 30px;
  }

  .header h1 {
    font-size: 2.5rem;
  }

  .form-section,
  .table-section {
    padding: 30px;
    margin-bottom: 30px;
  }

  /* Form Grid - Three Columns on Desktop */
  .form-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Large Form Grid - Two Columns for Complex Forms */
  .form-grid.large {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-content,
  .export-modal-content {
    max-width: 700px;
  }

  /* Export Options - Grid on Desktop */
  .export-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  /* Show table on desktop, hide cards */
  .mobile-card-view {
    display: none !important;
  }

  .table-container {
    display: block !important;
  }
}

/* Large Desktop - 1440px and up */
@media (min-width: 1440px) {
  .container {
    max-width: 1600px;
  }

  .form-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .form-grid.large {
    grid-template-columns: repeat(3, 1fr);
  }

  .export-options {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Very Small Screens - 375px and down */
@media (max-width: 375px) {
  .container {
    padding: 8px;
  }

  .header {
    padding: 15px 10px;
  }

  .header h1 {
    font-size: 1.6rem;
  }

  .form-section,
  .table-section {
    padding: 15px 10px;
  }

  .tabs {
    margin-bottom: 10px;
  }

  .tab {
    padding: 10px 6px;
    font-size: 13px;
    min-width: 100px;
  }

  /* Force card view on very small screens */
  .table-container {
    display: none !important;
  }

  .mobile-card-view {
    display: block !important;
  }

  .btn {
    padding: 12px 15px;
    font-size: 15px;
  }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .btn {
    border: 0.5px solid transparent;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #e9ecef;
  }

  .form-section,
  .table-section,
  .modal-content,
  .export-modal-content {
    background: #2d3748;
    color: #e9ecef;
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    background-color: #4a5568;
    border-color: #718096;
    color: #e9ecef;
  }

  .checkbox-item {
    background: #4a5568;
    border-color: #718096;
  }

  table {
    background: #2d3748;
  }

  tbody tr:hover {
    background-color: #4a5568;
  }

  tbody tr:nth-child(even) {
    background-color: #374151;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print Styles */
@media print {
  .btn,
  .tabs,
  .export-buttons,
  .modal,
  .export-modal {
    display: none !important;
  }

  .container {
    padding: 0;
  }

  .table-container {
    overflow: visible;
  }

  table {
    page-break-inside: auto;
  }

  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
}
