/* ============================================
   OrozcoyCo CC - Responsive Styles
   Media queries: mobile, tablet, desktop, print
   ============================================ */

/* ============================================
   DESKTOP FIRST BASE (> 1024px) handled in styles.css
   ============================================ */

/* ============================================
   TABLET (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }

  .main-content {
    margin-left: 220px;
  }

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

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

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

  .modal__body {
    padding: 1.25rem;
  }

  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================
   MOBILE (< 768px)
   ============================================ */
@media (max-width: 768px) {
  /* Sidebar: overlay mode */
  .sidebar {
    position: fixed;
    left: -260px;
    width: 260px;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }

  .sidebar.sidebar--open {
    left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
  }

  .sidebar-overlay.sidebar-overlay--visible {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  /* Header mobile */
  .header {
    padding: 0 1rem;
  }

  .header__menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    font-size: 1.5rem;
    margin-right: 0.75rem;
  }

  /* Dashboard KPIs: 1 column */
  .dashboard__kpis {
    grid-template-columns: 1fr;
  }

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

  /* Cards: full width */
  .card {
    border-radius: 0.5rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .page-header__actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .page-header__actions .btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }

  /* Forms: single column */
  .form-grid--2,
  .form-grid--3 {
    grid-template-columns: 1fr;
  }

  /* Modal: full screen on mobile */
  .modal__dialog {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    border-radius: 0;
    margin: 0;
    max-height: 100vh;
  }

  .modal__overlay {
    padding: 0;
    align-items: flex-start;
  }

  .modal__header {
    padding: 1rem;
  }

  .modal__body {
    padding: 1rem;
  }

  .modal__footer {
    padding: 1rem;
    flex-direction: column-reverse;
  }

  .modal__footer .btn {
    width: 100%;
  }

  /* Filters: stack */
  .filter-bar {
    flex-direction: column;
  }

  .filter-bar__search {
    width: 100%;
  }

  .filter-bar__filters {
    width: 100%;
    flex-wrap: wrap;
  }

  .filter-bar__filters select {
    flex: 1;
    min-width: 140px;
  }

  /* Calendar */
  .calendario__grid {
    font-size: 0.75rem;
  }

  .calendario__cell {
    min-height: 60px;
    padding: 0.25rem;
  }

  .calendario__layout {
    flex-direction: column;
  }

  .calendario__sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--color-border);
  }

  /* Tabs */
  .tabs__list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .tabs__btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Table: horizontal scroll */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Pagos table */
  .pagos__table th,
  .pagos__table td {
    padding: 0.5rem 0.4rem;
    font-size: 0.8rem;
  }

  /* Import/Export area */
  .drop-zone {
    padding: 2rem 1rem;
  }

  /* KPI card */
  .kpi-card {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  .kpi-card__icon {
    flex-shrink: 0;
  }

  /* Buttons */
  .btn--sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }

  /* Section fieldsets */
  .fieldset-section {
    padding: 1rem;
  }

  .fieldset-section legend {
    font-size: 0.9rem;
  }

  /* Matricula rows */
  .matricula-row__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* ============================================
   SMALL MOBILE (< 480px)
   ============================================ */
@media (max-width: 480px) {
  .header__title {
    font-size: 1rem;
  }

  .sidebar__brand {
    font-size: 1rem;
  }

  .kpi-card__value {
    font-size: 1.5rem;
  }

  .btn {
    font-size: 0.85rem;
  }

  .toast {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 1rem;
    max-width: none;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .sidebar,
  .header,
  .page-header__actions,
  .filter-bar,
  .btn,
  .tabs__list,
  .modal__overlay,
  .toast-container {
    display: none !important;
  }

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

  body {
    background: white !important;
    color: black !important;
    font-size: 11pt;
  }

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

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

  th, td {
    border: 1px solid #999;
    padding: 0.4rem 0.6rem;
    font-size: 10pt;
  }

  thead {
    background: #eee !important;
    color: black !important;
    print-color-adjust: exact;
  }

  .badge {
    border: 1px solid currentColor !important;
    background: transparent !important;
    print-color-adjust: exact;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }

  .page-break {
    page-break-before: always;
  }
}
