/* Responsive styles for the Flow State app */

/* Standard tablet breakpoint */
@media (max-width: 800px) {
  .container {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 0 16px;
  }
  
  /* All cards take full width on tablet and below */
  .card {
    grid-column: 1 / -1;
  }
}

/* Mobile layout */
@media (max-width: 600px) {
  body {
    padding: 0; 
    margin: 0;
    /* Remove body scroll for mobile app feel */
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .container {
    padding: 0 12px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    margin-bottom: env(safe-area-inset-bottom, 20px);
    gap: 16px;
  }


  /* Hide scroll bars on mobile for app-like feel */
  ::-webkit-scrollbar {
    width: 0px;
    background: transparent;
  }

  /* Remove the pull-to-refresh indicator space */
  body::before {
    display: none;
  }

  /* Fullscreen app feel */
  .header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: transparent; /* Start with transparent background */
    backdrop-filter: blur(10px); /* Always have a blur effect for better readability */
    -webkit-backdrop-filter: blur(10px);
    padding: calc(env(safe-area-inset-top, 8px) + 0px) 12px 8px 12px;
    margin: 0 0 16px 0;
    border-radius: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); /* Subtle shadow by default */
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px;
    align-items: center;
    width: 100%;
    transition: background-color 0.3s, box-shadow 0.3s, border-radius 0.5s ease-in-out;
  }
  
  /* Add solid background when scrolling */
  .header.scrolled {
    background-color: var(--card-bg);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
  }

  .header h1 {
    font-size: 1.6em;
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
  }

  .header-controls {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
  }

  #datetime {
    font-size: 0.9rem;
    grid-column: 1;
    grid-row: 2;
    margin-top: -4px;
    color: var(--muted);
  }

  .header .theme-dropdown-btn {
    padding: 4px;
  }

  .header .focus-btn {
    padding: 4px 8px;
  }

  .focus-text {
    display: none;
  }

  .header div:last-child {
    align-self: center;
    margin-top: 0;
  }

  #timer {
    font-size: 2.5rem;
  }

  #timerLabel {
    font-size: 0.9rem;
  }

  .controls {
    flex-wrap: wrap;
  }

  .controls button {
    flex: 1;
    min-width: 80px;
    padding: 12px 8px;
    margin-bottom: 8px;
  }

  #musicCard iframe {
    height: 180px;
  }

  #musicCard .controls {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: space-between;
  }

  #musicCard .controls button {
    flex: 1 0 auto;
    width: calc(33.333% - 6px); /* Change from 50% to 33.333% to fit 3 buttons per row */
    padding: 4px 2px;
    font-size: 0.75rem;
    margin-bottom: 5px;
    min-height: 34px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #customVidInput {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
  }

  /* Make buttons more touch-friendly */
  button,
  input[type="checkbox"],
  input {
    min-height: 44px;
  }

  #todoList li {
    padding: 8px 0;
  }

  /* Improve touch target size for todo actions */
  .todo-actions button {
    padding: 8px;
    margin: 0 4px;
  }

  /* App-like card style */
  .card {
    margin-bottom: 16px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-wrap: break-word !important;
  }
  
  /* Active card feedback */
  .card:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }

  /* Mobile app-like bottom navigation */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 5px 0 calc(5px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    justify-content: space-around;
    transition: transform 0.3s ease-out, background-color 0.3s;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
  }

  /* Hide navbar when scrolling down (optional) */
  .mobile-nav.hidden {
    transform: translateY(100%);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: color 0.2s, transform 0.2s;
    padding: 8px 0;
    width: 25%;
    position: relative;
  }

  .mobile-nav-item.active {
    color: var(--primary);
    transform: translateY(-2px);
  }

  /* Active indicator dot/pill */
  .mobile-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 4px;
    background-color: var(--primary);
    border-radius: 4px;
  }

  .mobile-nav-item i {
    font-size: 1.2rem;
    margin-bottom: 4px;
  }

  /* Add bottom padding to container for nav bar */
  .container {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  /* Enhanced touch feedback */
  button {
    position: relative;
    overflow: hidden;
  }

  button::after {
    content: '';
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.4) 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 0.5s;
  }

  button:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
  }

  /* Improved app-like modal */
  .modal-content {
    margin: 0;
    border-radius: 20px 20px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
    /* transform: translateY(100%); */
    transition: transform 0.3s ease-out;
    padding: 20px 15px calc(20px + env(safe-area-inset-bottom, 0px)) 15px;
  }

  .modal.active .modal-content {
    transform: translateY(0);
  }

  /* Add handle for app-like modals */
  .modal-content::before {
    content: '';
    display: block;
    width: 40px;
    height: 5px;
    background: #e0e0e0;
    border-radius: 5px;
    margin: -5px auto 15px auto;
  }
  
  .modal-form {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
  }
  
  .timer-presets {
    gap: 15px;
  }
  
  .preset-option {
    padding: 12px;
  }
  
  .preset-option input[type="radio"] {
    width: 20px;
    height: 20px;
  }
  
  .modal-save-btn {
    position: sticky;
    bottom: 0;
    margin-top: 15px;
    padding: 15px;
  }
}