/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
  .settings-container {
    padding: 1.25rem;
  }

  .table-title {
    font-size: 1.1rem;
  }

  .btn-menu.active {
    background-color: var(--primary-color) !important;
    color: white !important;
  }

  #save-pdf-button,
  #get-summary-button,
  #share-portfolio-button {
    font-size: 0.8rem;
    padding: 0.6rem 1rem !important;
  }

  /* Hide welcome message, portfolio analysis text, and login indicator on mobile */
  .welcome-email,
  .portfolio-analysis-text,
  [id*="bentornato"],
  [id*="portfoliopilot-analizzato"],
  .login-text,
  #login-indicator,
  #login-trigger {
    display: none !important;
    visibility: hidden !important;
  }

  /* Hide server migration warning on mobile */
  #server-migration-button,
  .server-migration-btn,
  #server-migration-popover {
    display: none !important;
    visibility: hidden !important;
  }

  /* Hide original floating buttons on mobile */
  .btn-menu {
    display: none !important;
  }

  /* Show the mobile navbar instead */
  .mobile-navbar {
    display: flex !important;
  }

  .login-text {
    display: none;
  }

  .counter-component {
    display: none !important;
  }

  .responsive-logo {
    max-height: 32px !important;
  }

  /* Table adjustments */
  .dash-spreadsheet th,
  .dash-spreadsheet td {
    padding: 12px 8px !important; /* Reduce padding on very small screens */
    font-size: 0.8rem !important; /* Slightly smaller font */
  }

  /* Add horizontal scroll indicator */
  .settings-container {
    position: relative;
  }

  .settings-container::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0;
    width: 15px;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(248, 249, 250, 0.9));
    pointer-events: none;
    z-index: 3;
  }

  /* Adjust spacing for very small screens */
  .mobile-navbar {
    padding: 8px 0;
  }

  .mobile-nav-btn {
    padding: 6px;
  }

  .mobile-nav-icon {
    font-size: 1rem;
  }

  /* Tabs and buttons container - all in one line */
  .tabs-buttons-container {
    justify-content: center !important;
    width: 100%;
    padding: 0 0.5rem;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
  }

  .mobile-tabs {
    width: 100%;
  }

  /* Linea compatta dei tab su mobile */
  .mobile-tabs .nav-tabs {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    border: none;
    background: transparent;
    overflow: hidden;
  }

  .mobile-tabs .nav-tabs .nav-item {
    flex: 1 !important;
    border: none;
    min-width: 0;
    max-width: 25%;
  }

  .mobile-tabs .nav-tabs .nav-link {
    flex: 1 !important;
    padding: 0.4rem 0.2rem;
    font-size: 0.7rem;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 0;
    margin: 0;
    display: block !important;
    width: 100% !important;
    min-width: 0;
  }

  .mobile-tabs .nav-tabs .nav-link.active {
    color: var(--primary-color);
    background: transparent;
    border-bottom: 3px solid var(--primary-color);
    border-top: none;
    border-left: none;
    border-right: none;
  }

  .mobile-tabs .nav-tabs .nav-link:hover {
    color: var(--primary-color);
    background: transparent;
    border: none;
  }

  /* Extra compact for very small screens */
  @media screen and (max-width: 480px) {
    .mobile-tabs .nav-tabs .nav-link {
      padding: 0.3rem 0.1rem;
      font-size: 0.65rem;
    }
  }

  /* Form elements for mobile */
  .form-select, .input-group-text {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 0.5rem 0.75rem;
  }

  /* Full-width modal buttons */
  .modal-footer .btn {
    margin: 0.25rem 0;
    width: 100%;
  }

  /* Stack modal footer buttons on mobile */
  .modal-footer {
    flex-direction: column;
  }

  .supporter-text {
    display: none !important;
  }

  .etf-badge {
    font-size: 0.875rem;
    padding: var(--spacing-xs) var(--spacing-sm);
  }

  /* Make rolling period dropdown full width on mobile */
  #rolling-period-dropdown {
    width: 100% !important;
  }

  /* Ensure the dropdown container takes full width on mobile */
  #rolling-period-dropdown-container {
    width: 100% !important;
    flex: 1 1 100% !important;
  }

  /* Force the Bootstrap column to take full width on mobile */
  .col-md-6, .col-sm-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  /* Target the specific row containing the rolling dropdown */
  .mb-3 {
    flex-direction: column !important;
  }

  /* Ensure the rolling dropdown container takes full width */
  #rolling-period-dropdown-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 15px !important;
  }

  /* Remove any constraining margins/padding from parent containers */
  .mb-3 > .col-md-6,
  .mb-3 > .col-sm-6 {
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Ensure the dropdown itself takes full width */
  #rolling-period-dropdown {
    width: 100% !important;
    min-width: 100% !important;
  }

  /* Override any card-like styling that might constrain width */
  #rolling-period-dropdown-container {
    border-radius: 8px !important;
    border: 2px solid #e9ecef !important;
    background-color: white !important;
    padding-top: 20px !important;
    width: calc(100% - 30px) !important;
    max-width: calc(100% - 30px) !important;
    margin-left: 15px !important;
    margin-right: 15px !important;
    box-sizing: border-box !important;
  }

  /* Padding orizzontale solo su mobile per il titolo del confronto */
  .title-mobile-pad {
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
  }
}

