/* ==========================================================
   TIMER.CSS – Stiluri exclusive pentru secțiunea Timer
   ========================================================== */

/* --------------------------
   Structura principală
   -------------------------- */
#section-timer .tool-content-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Spațiu între titlu și afișajul orei */
#section-timer .tool-title {
  margin-bottom: 1.5rem;
  display: block;
  text-align: center;
}

.timer-current-time {
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
}

/* --------------------------
   Butoane rapide (Quick Timers)
   -------------------------- */
.quick-timers-wrapper {
  margin: 1.5rem 0;
  text-align: center;
}

.quick-timers-label {
  display: block;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.quick-timers-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.quick-timer-btn {
  padding: 0.6rem;
  border: none !important;
  border-radius: 0.25rem;
  background: var(--surface-200);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
  text-align: center;
}

.quick-timer-btn:hover {
  border: none !important;
}

/* --------------------------
   Carduri Timer
   -------------------------- */
#timers-container {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.timer-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.timer-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.timer-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.timer-name {
  font-weight: 600;
  color: var(--text);
  font-size: 1.1rem;
}

.timer-display {
  font-family: 'Digital-7', 'Courier New', monospace;
  font-size: 1.5rem;
  color: var(--accent3);
  margin: 0.8rem 0;
}

.timer-progress {
  width: 100%;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  margin-top: 1rem;
  overflow: hidden;
}

.timer-progress-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  width: 100%;
  transition: width 0.3s ease;
}

.timer-controls-card {
  display: flex;
  gap: 0.8rem;
  margin-top: 1rem;
}

/* --------------------------
   Butoane principale
   -------------------------- */
#openTimerBtn,
#startTimerBtn {
  margin: 1rem 0;
  padding: 0.8rem 1.5rem;
}

/* --------------------------
   Modal Timer
   -------------------------- */
/* overlay-ul modalului: centrare orizontală + verticală */
/* overlay-ul modalului: centrare orizontală + verticală */
.timer-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

/* conținutul modalului (Set Alarm style override) */
.timer-modal-content {
  --radius: 8px;
}

.timer-modal-overlay:not(.hidden) {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.timer-modal-content {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
/* ─── Stiluri pentru Timer Modal ca în Alarm Modal ─── */
.timer-modal-content {
  /* ca în alarm.js: padding 2em; width 90%; max-width 420px; */
  padding: 2em !important;
  width: 90% !important;
  max-width: 420px !important;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.timer-modal-header h3 {
  /* font-size:1.4rem; margin:0; color var(--text) */
  font-size: 1.4rem;
  margin: 0 0 1.5em;
  color: var(--text);
}

.timer-modal-close-btn {
  /* butonul X din alarm: font-size 1.5em; padding .2em; */
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5em;
  cursor: pointer;
  padding: 0.2em;
}

.timer-modal-body form {
  /* layout form ca în alarm: flex-col cu gap 1.2em */
  display: flex;
  flex-direction: column;
  gap: 1.2em;
}

.timer-modal-body label {
  /* la fel ca în alarm: text-muted, fw600, mb .5em */
  display: block;
  margin-bottom: 0.5em;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.timer-modal-body input,
.timer-modal-body select {
  /* padding .7em, border 2px solid accent2, border-radius 8px */
  width: 100%;
  padding: 0.7em;
  font-size: 1rem;
  border: 2px solid var(--accent2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}

.timer-modal-body .modal-actions button {
  /* butonul principal Save/Start full-width, padding .8em */
  flex: 1;
  padding: 0.8em;
  border-radius: 8px;          /* same as Alarm buttons */
}

.timer-modal-body .modal-actions {
  /* pentru aliniere și gap identic cu Alarm */
  display: flex;
  gap: 0.8rem;
  margin-top: 1em;
}

.timer-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.timer-modal-header h3 {
  font-size: 1.3rem;
  color: var(--text);
}

.timer-modal-close-btn {
  background: none;
}
@media (min-width: 901px) {
  /* ─── Uniform styling for modal buttons ─── */
  .modal-actions button {
    padding: 0.8em 1.5em;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;          /* same as Alarm */
  }

  /* Preview, Custom Sound and secondary buttons */
  #previewTimerSoundBtn,
  #timerCustomSoundBtn,
  #timer-modal .secondary-btn {
    border-radius: 8px;          /* same as Alarm buttons */
  }
}
.timer-btn {
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.timer-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timer-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timer-field-group label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* --------------------------
   Stiluri noi pentru input-uri (asemănătoare cu alarm.css)
   -------------------------- */
.timer-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.timer-input-group > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.timer-input-group input {
  width: 100%;
  padding: 0.7em;
  border-radius: var(--radius);
  background: var(--bg);
  border: 2px solid var(--accent2);
  color: var(--text);
  text-align: center;
  font-size: 1rem;
}

.timer-input-group span {
  color: var(--text);
  font-weight: bold;
  margin: 0 0.2em;
}

.timer-input-field {
  width: 100%;
  padding: 0.7em;
  border-radius: var(--radius);
  background: var(--bg);
  border: 2px solid var(--accent2);
  color: var(--text);
}

.timer-input:focus,
.timer-input-field:focus {
  border-color: var(--accent3);
  box-shadow: 0 0 0 2px rgba(0, 178, 255, 0.2);
}

/* --------------------------
   Control sunet
   -------------------------- */
/* Checkbox wrapper styling */
.timer-checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.5rem;
  
  /* prevent full-width stretching */
  align-self: flex-start;
}
.sound-controls-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#timer-sound {
  flex: 1;
  padding: 0.7em;
  border-radius: var(--radius);
  background: var(--bg);
  border: 2px solid var(--accent2);
  color: var(--text);
}

#previewTimerSoundBtn {
  padding: 0.7em;
  border-radius: var(--radius);
  background: var(--bg);
  border: 2px solid var(--accent2);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}

#previewTimerSoundBtn:hover {
  background: var(--accent2);
  color: white;
}

#previewTimerSoundBtn.playing {
  background: var(--accent2);
  color: white;
}

/* --------------------------
   Opțiuni recurente
   -------------------------- */
.timer-checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.5rem;
}

.timer-checkbox-wrapper label {
  color: var(--text-muted);
  cursor: pointer;
}

#timer-days-container {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.day-toggle-btn {
  padding: 0.5rem 0.8rem;
  border-radius: 0.4rem;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--accent2);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

.day-toggle-btn.active {
  background: var(--accent2);
  color: white;
  border-color: var(--accent2);
}

/* --------------------------
   Mobile Time Picker Styles
   -------------------------- */
@media (max-width: 900px) {
  .timer-input-group-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    width: 100%;
  }

  .timer-input-group-mobile label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
  }

  .timer-select {
    width: 100%;
    padding: 1em;
    border-radius: var(--radius);
    background: var(--bg);
    border: 2px solid var(--accent2);
    color: var(--text);
    font-size: 1.1rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='%23b0b3c6' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 20px 16px;
  }

  .timer-select:focus {
    border-color: var(--accent3);
    box-shadow: 0 0 0 3px rgba(0, 178, 255, 0.2);
    outline: none;
  }

  /* Hide desktop inputs on mobile */
  .timer-input-group > div:not(.timer-input-group-mobile) {
    display: none;
  }

  .timer-modal-content {
    padding: 1.5rem;
    width: 95%;
    max-width: none;
    margin: 0.5rem;
  }

  .timer-modal-body {
    gap: 1.5rem;
  }

  .modal-actions button {
    padding: 1em;
    font-size: 1.1rem;
  }
  
  .quick-timers-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }

  .quick-timer-btn {
    padding: 1rem;
  }
}

/* === Patch 2025-08-10: Fullscreen modal pe telefon + iOS safe-area === */
@media (max-width: 900px) {
  .timer-modal-overlay.fullscreen-modal {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
  }
  .timer-modal-content {
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    height: -webkit-fill-available !important; /* fallback iOS */
    max-height: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: calc(env(safe-area-inset-top, 0px) + 0.9rem) 0.9rem 0.9rem !important;
    overscroll-behavior: contain !important;
    overflow-y: auto !important;
  }
  body.no-scroll {
    overflow: hidden !important;
    height: 100dvh !important;
    touch-action: none !important;
  }
}

@keyframes scaleIn {
  from { transform: scale(.98); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

/* Apare cu zoom-in ușor când overlay-ul devine vizibil */
.timer-modal-overlay:not(.hidden) .timer-modal-content {
  animation: scaleIn .2s ease;
}

/* === Patch 2025-08-10: Sticky Start button pe telefon === */
@media (max-width: 900px) {
  .timer-modal-content .timer-modal-body {
    padding-bottom: 5rem !important; /* spațiu pentru buton */
  }
  .timer-modal-content .timer-start-btn {
    position: sticky;
    bottom: 0;
    display: block;
    width: 100%;
    margin-top: 1rem;
    z-index: 2;
  }
}
.timer-controls {
  font-size: 1rem;
  }

  .timer-card {
    padding: 1.5rem;
  }

  .timer-display {
    font-size: 1.8rem;
    margin: 1rem 0;
  }

  .timer-controls-card {
    gap: 1rem;
  }

/* Keep desktop styles for larger screens */
@media (min-width: 901px) {
  .timer-input-group-mobile {
    display: none !important;
  }
}

/* --------------------------
   Tema Light
   -------------------------- */
body.light-mode .timer-card {
  background: var(--surface-100);
  border: 1px solid var(--surface-200);
}

body.light-mode .timer-input,
body.light-mode .timer-input-field,
body.light-mode #timer-sound,
body.light-mode #previewTimerSoundBtn {
  background: var(--surface-100);
  border-color: #cbd5e0;
}

body.light-mode .timer-modal-content {
  background: var(--surface-300);
}

body.light-mode .quick-timer-btn {
  background: var(--surface-100);
}

/* --------------------------
   Responsive
   -------------------------- */
@media (max-width: 600px) {
  .timer-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .timer-display {
    font-size: 1.3rem;
  }

  .timer-modal-content {
    padding: 1rem;
    width: 95%;
  }

  .timer-input-group {
    gap: 0.3rem;
  }

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

@media (max-width: 400px) {
  .timer-input {
    max-width: 48px;
    font-size: 0.9rem;
  }

  .timer-checkbox-wrapper {
    gap: 0.5rem;
  }
}

/* Animații */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (min-width: 901px) {
  /* ─── Stil unificat pentru butoanele din modaluri ─── */
  .modal-actions button,
  /* pentru alarma expirată */
  .alarm-firing-modal .modal-actions button {
    padding: 0.8em 1.5em;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
  }

  /* Buton principal (Start / Save) */
  .modal-actions .main-btn,
  /* dacă nu foloseşti main-btn, poţi aplica selectorul generic: */
  .modal-actions button[type="submit"] {
    background: var(--accent2);
    color: white;
  }
  .modal-actions .main-btn:hover,
  .modal-actions button[type="submit"]:hover {
    background: var(--accent1);
  }

  /* Buton secundar (Cancel / Close) */
  .modal-actions .secondary-btn,
  .modal-actions button.cancel-btn {
    background: var(--bg);
    border: 2px solid var(--accent2);
    color: var(--text);
  }
  .modal-actions .secondary-btn:hover,
  .modal-actions button.cancel-btn:hover {
    background: var(--accent2);
    color: white;
  }

  /* Butonul „X” de închidere */
  .timer-modal-close-btn,
  .alarm-modal .modal-close-btn {
    padding: 0.2em;
    font-size: 1.2rem;
    background: none;
    border: none;
    color: var(--text-muted);
  }
}
@media (min-width: 901px) {
  /* ─── Unify corner radius to 8px (var(--radius)) ─── */
  #timer-modal .timer-modal-content 
    .timer-input-field,
  #timer-modal .timer-input-group .timer-input,
  #timer-modal .timer-modal-content select.timer-sound-select,
  #timer-modal .timer-modal-content .secondary-btn,
  #timer-modal .timer-checkbox-wrapper input {
    border-radius: var(--radius); /* 8px in your theme */  
  }

  /* ─── Same padding, border and background as "Name" ─── */
  #timer-modal .timer-modal-content 
    .timer-input-field,
  #timer-modal .timer-input-group .timer-input,
  #timer-modal .timer-modal-content select.timer-sound-select {
    padding: 0.7em;
    border: 2px solid var(--accent2);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    font-weight: 400;
    text-align: center;
    transition: border-color 0.2s ease;
  }

  /* ─── Accent border on focus ─── */
  #timer-modal .timer-modal-content 
    .timer-input-field:focus,
  #timer-modal .timer-input-group .timer-input:focus,
  #timer-modal .timer-modal-content select.timer-sound-select:focus {
    outline: none;
    border-color: var(--accent1);
  }
}
/* Checkbox wrapper styling */
.timer-checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 0.4rem;          /* space between box and label */
  margin-top: 0.5rem;
}
/* Checkbox label styling */
.timer-modal-body .timer-checkbox-wrapper label {
  display: inline-block;      /* Override display:block */
  margin-bottom: 0;           /* Remove default margin */
}
/* Checkbox input styling */
.timer-modal-body .timer-checkbox-wrapper input[type="checkbox"] {
  width: 1.2em;    /* same width as Alarm */
  height: 1.2em;   /* square aspect ratio */
  flex-shrink: 0;  /* prevent stretching */
  margin: 0;       /* remove unwanted margins */
}

/* ───────────────────────────────
   MOBIL (<= 900px): fullscreen
   ─────────────────────────────── */
@media (max-width: 900px) {
  .timer-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 0 !important;
    box-shadow: none !important;
    animation: none !important;
    z-index: 1000;
    backdrop-filter: blur(2px);
  }
  
  .timer-modal-overlay:not(.hidden) {
    display: flex;
  }
  
  .timer-modal-content {
    width: 100%;
    height: 100dvh;
    margin: 0 !important;
    padding: .75rem !important;
    border-radius: 0 !important;
    background: var(--card-bg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overscroll-behavior: contain;
  }
  
  /* Butonul de submit full-width pe mobil */
  .timer-start-btn {
    width: 100%;
  }
}


@media (max-width: 900px) {
  /* Stretch the overlay to behave like a page */
  .timer-modal-overlay {
    align-items: stretch !important;
    justify-content: stretch !important;
    backdrop-filter: blur(2px);
  }

  /* Make the modal content full-bleed and full-height */
  .timer-modal-content {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: calc(env(safe-area-inset-top, 0) + .9rem) .9rem .9rem .9rem !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column;
    justify-content: flex-start;
    overscroll-behavior: contain;
    overflow: auto;
  }

  /* Make primary action full-width if present */
  #timer-modal .timer-start-btn {
    width: 100% !important;
  }

  /* (Optional, controlled from JS) Prevent background scroll while modal open */
  body.no-scroll {
    overflow: hidden;
    height: 100dvh;
    touch-action: none;
  }
}

/* Small fade-in, in case it's missing above */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (max-width: 900px) {
  /* Overlay Timer – fullscreen ca Alarm */
  .timer-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
    z-index: 1000;
    backdrop-filter: blur(2px);
  }

  .timer-modal-overlay:not(.hidden) {
    display: flex;
  }

  .timer-modal-overlay.fullscreen-modal {
    align-items: stretch;
    justify-content: stretch;
  }

  .timer-modal-content {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: calc(env(safe-area-inset-top, 0) + 0.9rem) 0.9rem 0.9rem;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overscroll-behavior: contain;
    overflow-y: auto;
  }

  body.no-scroll {
    overflow: hidden;
    height: 100dvh;
    touch-action: none;
  }

  /* Butonul Start/Submit full-width */
  .timer-start-btn {
    width: 100%;
  }
}


/* ---- Non-blocking toast for Timer ---- */
.timer-toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  background: var(--card-bg);
  color: var(--text);
  border: 2px solid var(--accent2);
  border-radius: 8px;
  padding: .6rem .8rem;
  box-shadow: var(--shadow);
  display: flex;
  gap: .5rem;
  align-items: center;
  z-index: 3000;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
}
.timer-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.timer-toast-btn {
  padding: .4rem .6rem;
  font-size: .9rem;
  border-radius: 6px;
  border: 2px solid var(--accent2);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
