/* Responsive CSS - Mobile-first approach */

/* CSS Variables for breakpoints (for reference):
 * Mobile: < 768px
 * Tablet: 768px - 1024px
 * Desktop: > 1024px
 */

/* Mobile menu toggle button - hidden by default on desktop */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1001;
  background-color: var(--primary-main);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 15px;
  font-size: 2rem;
  cursor: pointer;
}

.mobile-menu-toggle:hover {
  background-color: var(--brand-primary-dark);
}

/* Mobile overlay when sidebar is open */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 998;
}

.mobile-overlay.active {
  display: block;
}

/* =====================================================
   TABLET STYLES (768px - 1024px)
   ===================================================== */
@media screen and (max-width: 1024px) {
  /* Reduce sidebar width */
  nav {
    width: 80px;
  }

  .dashboard-menu {
    width: 100%;
  }

  /* Hide sidebar text labels on tablet */
  .vertical-menu-item span,
  .logout-button span {
    display: none;
  }

  /* Center icons */
  .vertical-menu-item,
  .logout-button {
    justify-content: center;
    padding: 12px;
  }

  /* Reduce main content padding */
  .horizontal-padding {
    padding-left: 20px;
    padding-right: 20px;
  }

  /* Responsive tables */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  /* Warning message modal */
  .exit-warning-message {
    width: 80%;
    min-width: auto;
    max-width: none;
    padding: 20px;
  }

  .exit-warning-message h3 {
    font-size: 2.4rem;
  }

  .exit-warning-message p {
    font-size: 1.6rem;
  }
}

/* =====================================================
   MOBILE STYLES (< 768px)
   ===================================================== */
@media screen and (max-width: 768px) {
  /* Show mobile menu toggle */
  .mobile-menu-toggle {
    display: block;
  }

  /* Sidebar wrapper transforms to slide-out menu */
  .vertical-menu {
    position: fixed;
    left: -280px;
    top: 0;
    width: 280px !important;
    min-width: 280px !important;
    height: 100vh;
    z-index: 999;
    background-color: white;
    transition: left 0.3s ease-in-out;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  }

  .vertical-menu.mobile-open {
    left: 0;
  }

  /* Hide the desktop hide/show button on mobile */
  .hide-show-menu-button {
    display: none;
  }

  /* Ensure nav takes full width inside sidebar */
  .vertical-menu nav {
    width: 100%;
    height: 100%;
  }

  /* Show sidebar text labels when menu is open */
  .vertical-menu.mobile-open .vertical-menu-option span {
    display: inline;
  }

  /* Ensure menu options show text properly on mobile when open */
  .vertical-menu.mobile-open .vertical-menu-option {
    justify-content: flex-start;
    padding: 15px;
  }

  /* Main content takes full width */
  main {
    flex-direction: column;
    width: 100%;
  }

  .dashboard-menu {
    width: 100%;
    border-left: none;
  }

  /* Add top padding for mobile menu button */
  .dashboard-menu-principal {
    padding-top: 70px;
  }

  /* Reduce padding */
  .horizontal-padding {
    padding-left: 15px;
    padding-right: 15px;
  }

  /* Stack form elements vertically */
  .form-row,
  .inputs-container {
    flex-direction: column;
  }

  .form-row > *,
  .inputs-container > * {
    width: 100% !important;
    margin-bottom: 15px;
  }

  /* Full-width buttons on mobile */
  .primary-button,
  .secondary-button,
  .confirm-exit-button,
  .decline-exit-button {
    width: 100%;
    min-height: 48px; /* Touch-friendly size */
  }

  /* Stack footer buttons */
  .adjust-warning-exit-buttons {
    flex-direction: column;
    gap: 10px;
  }

  /* Modal adjustments */
  .exit-warning-message {
    width: 90%;
    min-width: auto;
    max-width: none;
    height: auto;
    min-height: auto;
    max-height: none;
    padding: 20px;
  }

  .container-title-exit-warning h3 {
    font-size: 2rem;
  }

  /* Responsive tables - card layout on mobile */
  table {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: block;
  }

  tr {
    display: block;
    margin-bottom: 15px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  td {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--neutral-200);
  }

  td:last-child {
    border-bottom: none;
  }

  td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--neutral-600);
    margin-right: 10px;
  }

  /* Action buttons in table cells */
  td .action-buttons {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Login page adjustments */
  .login-container {
    flex-direction: column;
  }

  .login-left-side {
    display: none; /* Hide decorative side on mobile */
  }

  .login-right-side {
    width: 100%;
    padding: 20px;
  }

  .adjust-right-side,
  .adjust-right-side-email,
  .adjust-right-side-password {
    width: 100%;
    max-width: 100%;
    padding: 0;
  }

  .login-title,
  .reset-password-title {
    font-size: 2.4rem;
  }

  /* Component header adjustments */
  .component-header h2 {
    font-size: 2rem;
  }

  /* Container adjustments */
  .component-container {
    flex-direction: column;
  }

  .screen-container {
    padding: 10px;
  }

  /* Footer adjustments */
  .action-footer,
  .action-footer-extended {
    flex-direction: column;
    gap: 10px;
    padding: 15px;
  }

  .action-footer button,
  .action-footer-extended button,
  .action-footer a,
  .action-footer-extended a {
    width: 100%;
  }

  /* =====================================================
     PAGE-SPECIFIC MOBILE STYLES
     ===================================================== */

  /* === FORM CONTAINERS === */
  .discount-form-container,
  .collaborator-form,
  .reminder-form-container,
  .month-config-form-container,
  .invoice-form-container,
  .overtime-rate-form-container {
    width: 100% !important;
    padding: 0 10px;
  }

  /* === FORM GROUPS - Stack vertically === */
  .form-group,
  .adjust-input-container,
  .input-row,
  .form-inputs-row {
    flex-direction: column !important;
    gap: 16px !important;
    width: 100% !important;
  }

  .form-group > *,
  .adjust-input-container > *,
  .input-row > *,
  .form-inputs-row > * {
    width: 100% !important;
    min-width: 100% !important;
  }

  /* === GRID LAYOUTS - Single column on mobile === */
  .adjust-component-container {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
  }

  .container-description {
    margin-right: 0 !important;
    margin-bottom: 16px;
  }

  /* === COMPONENT HEADERS === */
  .component-header,
  .discounts-visualization-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 16px !important;
  }

  .component-header h2,
  .discounts-visualization-header h2 {
    font-size: 2rem !important;
    margin-bottom: 8px;
  }

  .header-buttons {
    width: 100%;
    flex-direction: column;
    gap: 10px;
  }

  .header-buttons > * {
    width: 100% !important;
    justify-content: center;
  }

  /* === ACTION CARDS === */
  .action-card,
  .card-container {
    padding: 16px !important;
  }

  .action-card-content {
    flex-direction: column !important;
    text-align: center;
  }

  .action-card-content img {
    margin-bottom: 16px;
  }

  /* Add top margin to action buttons inside cards */
  .card-container .button-container,
  .card-container > a,
  .card-container > button,
  .action-card .button-container,
  .action-card > a,
  .action-card > button {
    margin-top: 16px !important;
  }

  .button-secondary-with-arrow {
    margin-top: 12px !important;
  }

  /* === TABLES === */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* === INPUT FIELDS === */
  .input-container,
  .select-container,
  .textarea-container {
    width: 100% !important;
  }

  .input-container input,
  .input-container select,
  .input-container textarea,
  .select-container select,
  .textarea-container textarea {
    width: 100% !important;
  }

  /* === COLLABORATOR PAGES === */
  .collaborator-details-container,
  .collaborator-info-container {
    flex-direction: column !important;
  }

  .collaborator-avatar {
    margin: 0 auto 20px auto;
  }

  /* === PAYMENTS PAGES === */
  .payment-details-container,
  .payment-info-grid {
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
  }

  .payment-summary-card {
    width: 100% !important;
  }

  /* === WORKED HOURS PAGES === */
  .hours-summary-container,
  .hours-details-grid {
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
  }

  .calendar-container {
    overflow-x: auto;
  }

  /* === INVOICE PAGES === */
  .invoice-details-container,
  .invoice-info-grid {
    flex-direction: column !important;
  }

  .invoice-file-container {
    width: 100% !important;
  }

  /* === CONFIG PAGES === */
  .config-form-container,
  .overtime-config-container {
    width: 100% !important;
  }

  .config-list-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px;
  }

  /* === REMINDER PAGES === */
  .reminder-container,
  .reminder-details {
    flex-direction: column !important;
  }

  /* === MONTH CONFIG PAGES === */
  .month-config-container,
  .month-config-list {
    width: 100% !important;
  }

  .month-config-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px;
  }

  /* === BUTTON CONTAINERS === */
  .button-container,
  .buttons-row,
  .action-buttons-container {
    flex-direction: column !important;
    gap: 10px !important;
    width: 100%;
  }

  .button-container > *,
  .buttons-row > *,
  .action-buttons-container > * {
    width: 100% !important;
  }

  /* === NAVIGATION TABS === */
  .navigation-tabs,
  .tabs-container,
  nav.navigation-tabs-container,
  .navigation-tabs-container {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    gap: 4px;
    padding-bottom: 0;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    width: 100% !important;
    max-width: 100% !important;
  }

  .navigation-tabs-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }

  .navigation-tabs > *,
  .tabs-container > *,
  .navigation-tabs-container > * {
    flex-shrink: 0 !important;
  }

  .tab-container {
    min-width: auto !important;
    flex-shrink: 0 !important;
  }

  .tab-text {
    font-size: 13px !important;
    padding: 8px 12px !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  /* Ensure the navigation container allows horizontal scroll */
  .navigation-container {
    width: 100% !important;
    overflow-x: visible !important;
  }

  /* === FILTER COMPONENTS === */
  .filter-container,
  .filter-form {
    flex-direction: column !important;
    width: 100%;
  }

  .filter-container > *,
  .filter-form > * {
    width: 100% !important;
  }

  /* === STATUS BADGES === */
  .status-badge,
  .tag-status {
    font-size: 12px;
    padding: 4px 8px;
  }

  /* === PAGINATION === */
  .pagination-container {
    flex-direction: column !important;
    gap: 16px;
    align-items: center;
  }

  .pagination-info {
    order: 2;
  }

  .pagination-controls {
    order: 1;
  }

  /* === EMPTY STATES === */
  .empty-state-container {
    padding: 24px 16px !important;
    text-align: center;
  }

  .empty-state-container img {
    max-width: 150px;
  }

  /* === MODALS AND ALERTS === */
  .modal-content,
  .alert-modal-content {
    width: 95% !important;
    max-width: none !important;
    margin: 10px;
    padding: 16px !important;
  }

  .modal-header h3,
  .alert-title {
    font-size: 1.8rem !important;
  }

  /* === INFO BOXES === */
  .info-box,
  .warning-box,
  .success-box {
    padding: 12px !important;
    font-size: 14px;
  }

  /* === FORM TITLES === */
  .form-title,
  .page-title {
    font-size: 2rem !important;
    margin-bottom: 16px;
  }

  .form-subtitle,
  .section-title {
    font-size: 1.6rem !important;
  }

  /* === DESCRIPTION TEXT === */
  .container-description p,
  .form-description {
    font-size: 14px !important;
  }

  /* === CUSTOM TABLES (collaborators, discounts, etc.) === */
  .collaborators-table,
  .discounts-table,
  .payments-table,
  .worked-hours-table {
    display: block !important;
    width: 100% !important;
  }

  .collaborators-table thead,
  .discounts-table thead,
  .payments-table thead,
  .worked-hours-table thead {
    display: none !important;
  }

  .collaborators-table tbody,
  .discounts-table tbody,
  .payments-table tbody,
  .worked-hours-table tbody,
  .table-collaborator-tbody {
    display: block !important;
    width: 100% !important;
  }

  .collaborators-table .table-data-row,
  .discounts-table .table-data-row,
  .payments-table .table-data-row,
  .worked-hours-table .table-data-row {
    display: block !important;
    margin-bottom: 16px !important;
    padding: 16px !important;
    background-color: white !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    border: 1px solid var(--neutral-200) !important;
  }

  .collaborators-table .table-data,
  .collaborators-table .table-data-view,
  .discounts-table .table-data,
  .payments-table .table-data,
  .worked-hours-table .table-data {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 8px 0 !important;
    border-bottom: 1px solid var(--neutral-100) !important;
    flex: none !important;
    width: 100% !important;
  }

  .collaborators-table .table-data:last-of-type,
  .collaborators-table .table-data-view,
  .discounts-table .table-data:last-of-type,
  .payments-table .table-data:last-of-type,
  .worked-hours-table .table-data:last-of-type {
    border-bottom: none !important;
  }

  .collaborators-table .table-data::before,
  .discounts-table .table-data::before,
  .payments-table .table-data::before,
  .worked-hours-table .table-data::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--neutral-600);
    font-size: 14px;
    min-width: 80px;
    flex-shrink: 0;
  }

  .collaborators-table .table-data-text,
  .discounts-table .table-data-text,
  .payments-table .table-data-text,
  .worked-hours-table .table-data-text {
    text-align: right !important;
    font-size: 14px !important;
    word-break: break-word !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  .collaborators-table .table-data-view,
  .discounts-table .table-data-view,
  .payments-table .table-data-view,
  .worked-hours-table .table-data-view {
    justify-content: center !important;
    padding-top: 12px !important;
  }

  .collaborators-table .button-data-eye,
  .discounts-table .button-data-eye,
  .payments-table .button-data-eye,
  .worked-hours-table .button-data-eye {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px;
    background-color: var(--primary-main);
    border-radius: 8px;
  }

  .collaborators-table .button-data-eye img,
  .discounts-table .button-data-eye img,
  .payments-table .button-data-eye img,
  .worked-hours-table .button-data-eye img {
    filter: brightness(0) invert(1);
  }

  /* Container table adjustments */
  .container-table-collaborators,
  .container-table-discounts,
  .container-table-payments {
    overflow-x: visible !important;
    padding: 0 !important;
  }
}

/* =====================================================
   SMALL MOBILE STYLES (< 480px)
   ===================================================== */
@media screen and (max-width: 480px) {
  html {
    font-size: 55%; /* Slightly smaller base font */
  }

  .horizontal-padding {
    padding-left: 10px;
    padding-right: 10px;
  }

  .component-header h2 {
    font-size: 1.8rem;
  }

  /* Smaller modals */
  .exit-warning-message {
    width: 95%;
    padding: 15px;
  }

  .container-title-exit-warning h3 {
    font-size: 1.8rem;
  }

  .close-exit-warning {
    width: 32px;
    height: 32px;
  }
}

/* =====================================================
   UTILITY CLASSES
   ===================================================== */

/* Hide on mobile */
.hide-mobile {
  display: block;
}

@media screen and (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}

/* Show only on mobile */
.show-mobile {
  display: none;
}

@media screen and (max-width: 768px) {
  .show-mobile {
    display: block !important;
  }
}

/* Hide on tablet and below */
.hide-tablet {
  display: block;
}

@media screen and (max-width: 1024px) {
  .hide-tablet {
    display: none !important;
  }
}

/* Responsive text alignment */
@media screen and (max-width: 768px) {
  .text-center-mobile {
    text-align: center !important;
  }
}

/* Touch-friendly elements */
@media screen and (max-width: 768px) {
  button,
  a.button,
  .clickable,
  input[type="submit"],
  input[type="button"] {
    min-height: 44px; /* Apple's recommended minimum touch target */
    min-width: 44px;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px; /* Prevents iOS zoom on focus */
    min-height: 44px;
    padding: 10px 15px;
  }
}

/* Print styles */
@media print {
  nav,
  .mobile-menu-toggle,
  .mobile-overlay,
  .action-footer,
  .action-footer-extended {
    display: none !important;
  }

  main {
    width: 100% !important;
  }

  .dashboard-menu {
    width: 100% !important;
    border: none !important;
  }
}
