/* ============================================
   Reset y estilos base
   ============================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: "Inter", sans-serif;
  background: var(--gray-100);
  color: var(--gray-700);
  display: flex;
  flex-direction: column;
}

/* ============================================
   Variables base para Light Mode
   ============================================ */
:root {
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --danger-600: #dc2626;
  --gray-100: #f3f4f6;
  --gray-700: #374151;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Estilos globales
   ============================================ */
.container {
  flex: 1;
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* HEADER */
.header {
  text-align: center;
  margin-bottom: 2.5rem;
}
.header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-500);
  margin-bottom: 0.5rem;
}
.header p {
  font-size: 1rem;
  color: var(--gray-700);
  margin-top: 0.5rem;
}

/* TIMERS */
.timer-display {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin: 2rem 0;
}
.timer-card {
  background: white;
  padding: 2rem;
  border-radius: 1.5rem;
  box-shadow: var(--shadow-md);
  text-align: center;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.timer-card h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  font-weight: 600;
  margin-bottom: 1rem;
  display: block;
  min-height: 2rem;
  line-height: 2rem;
  width: 250px;
  margin: 0 auto 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timer {
  font-size: calc(2rem + 1vw);
  font-weight: 700;
  margin: 1rem 0;
  color: var(--primary-500);
}
#totalTimer {
  color: var(--gray-700);
}
.progress-container {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  margin: 1rem 0;
  position: relative;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary-500);
  border-radius: 4px;
  transition: width 0.5s ease;
  position: absolute;
  right: 0;
  width: 0%;
}

/* CONTROLS */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 2rem 0;
}
.controls-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
  width: auto;
}

/* Botones base */
.btn {
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
}
.btn-primary {
  background: var(--primary-500);
  color: white;
}
.btn-danger {
  background: var(--danger-600);
  color: white;
}
.btn-secondary {
  background: #6b7280;
  color: white;
}
.btn-info {
  background: #8b5cf6;
  color: white;
  padding: 0.8rem 1.5rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.square-btn {
  width: 50px;
  height: 50px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border-radius: 0.75rem;
}

/* BLOCK EDITOR */
.block-editor {
  background: white;
  padding: 2rem;
  border-radius: 1.5rem;
  box-shadow: var(--shadow-md);
  margin: 2rem 0;
  width: 100%;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}
.input-group {
  display: grid;
  grid-template-columns: 1fr 1fr 100px auto;
  gap: 1rem;
  margin-bottom: 1rem;
}
.input-field {
  padding: 0.8rem;
  border: 2px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 1rem;
  transition: border-color 0.2s;
  min-width: 80px;
}
.input-field:focus {
  outline: none;
  border-color: var(--primary-500);
}

/* BLOCK LIST */
.block-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 2rem;
  align-items: center;
  width: 100%;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* BLOCK ITEM */
.block-item {
  background: white;
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  cursor: move;
  transition: background 0.2s;
  width: 100%;
  max-width: 700px;
}
.block-item:hover {
  background: #f9fafb;
}
.block-item.active {
  border-left: 4px solid var(--primary-500);
  background: #f0f4ff;
}
.block-item.drag-over {
  background-color: #e0e7ff;
}
.block-time {
  font-weight: 600;
  width: 100px;
  text-align: center;
}
.block-content {
  flex: 1;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.block-content input.edit-input {
  margin-right: 0.5rem;
}
.time-label {
  font-size: 0.9rem;
  color: #555;
  vertical-align: middle;
  margin-left: 0.25rem;
}
.block-actions {
  display: flex;
  gap: 0.5rem;
}
.delete-btn {
  background: var(--danger-600);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

/* FOOTER */
.footer-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* MODAL */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 20px;
  border-radius: 1rem;
  box-shadow: var(--shadow-md);
  max-width: 500px;
  position: relative;
}
.modal-content h2 {
  margin-bottom: 1rem;
}
.modal-content .close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
}

/* FOOTER (resto) */
footer {
  background: var(--gray-100);
  padding: 2rem;
  text-align: center;
  margin-top: auto;
}
footer p {
  margin-top: 1rem;
  color: #555;
  line-height: 1.4;
  font-size: 0.95rem;
}

/* ============================================
   Media Queries combinados (min-width: 768px y max-width: 767px)
   ============================================ */
@media (min-width: 768px) {
  .footer-buttons {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }
  .footer-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
  }
  .footer-row .btn,
  .footer-row label {
    flex: 0 0 200px;
    width: 200px;
    max-width: 200px;
    margin: 0 auto;
  }
  .block-content.editing-mode > div {
    margin-bottom: 0.5rem;
  }
}

@media (max-width: 767px) {
  .footer-buttons {
    flex-direction: column;
    gap: 1rem;
  }
  .footer-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  .footer-row .btn,
  .footer-row label {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }
  .container {
    width: 95%;
    margin: 0 auto;
    padding: 1rem;
  }
  .controls {
    width: 95%;
    margin: 0 auto;
  }
  .controls-row {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }
  .controls-row button.square-btn {
    width: calc((100% - 20px) / 3);
  }
  .controls-row button.manual-btn {
    width: 100%;
    flex-basis: 100%;
    margin-top: 10px;
  }
  .header h1 {
    font-size: 1.75rem;
  }
  .header p {
    font-size: 0.95rem;
  }
  .timer-display {
    grid-template-columns: 1fr;
  }
  .block-editor {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
  }
  .block-item {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .block-time {
    width: 100%;
    text-align: left;
  }
  .block-content input.edit-input {
    display: block;
    width: 100%;
    margin: 0 0 0.5rem 0;
  }
  .time-label {
    display: block;
    margin: 0 0 0.5rem 0;
  }
  .block-actions {
    flex-direction: row;
    gap: 0.5rem;
    justify-content: space-between;
  }
  .block-actions button {
    width: auto;
    flex: 1 1 auto;
  }
  .input-group {
    grid-template-columns: 1fr;
  }
  .timer-card h2 {
    font-size: 0.9rem;
    padding-right: 0.5rem;
    width: auto;
    min-height: auto;
    line-height: normal;
  }
}

/* ============================================
   Estilos para Dark Mode (por herencia global)
   ============================================ */
.dark-mode,
.dark-mode p,
.dark-mode h1,
.dark-mode h2,
.dark-mode h3,
.dark-mode h4,
.dark-mode h5,
.dark-mode h6,
.dark-mode span,
.dark-mode div,
.dark-mode a,
.dark-mode li,
.dark-mode input,
.dark-mode button,
.dark-mode label,
.dark-mode textarea {
  color: #f0ead6 !important;
}
.dark-mode {
  background-color: #121212;
}
.dark-mode .container,
.dark-mode .header,
.dark-mode footer {
  background-color: #121212;
}
.dark-mode .block-list {
  background: transparent;
}
.dark-mode .timer-card,
.dark-mode .block-editor,
.dark-mode .block-item {
  background-color: #1e1e1e;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.8);
  border: 1px solid #333;
}
.dark-mode .block-item.active {
  border-left: 4px solid #f0ead6;
  background: #1e1e1e;
}
.dark-mode .input-field {
  background-color: #2c2c2c;
  border: 2px solid #555;
}
.dark-mode ::placeholder {
  color: #aaa;
}
.btn-dark {
  background: #1e1e1e;
  color: #f0ead6;
}
.dark-mode .btn {
  background-color: #2c2c2c;
  border: 2px solid #555;
  color: #f0ead6;
}
.dark-mode .btn.btn-dynamic.active {
  background-color: var(--primary-500);
  border: none;
  color: white;
}
.btn:hover:not(:disabled) {
  filter: brightness(90%) !important;
  box-shadow: var(--shadow-sm) !important;
}
.dark-mode .btn:hover:not(:disabled) {
  filter: brightness(90%) !important;
  box-shadow: var(--shadow-sm) !important;
}
.dark-mode .delete-btn {
  background-color: #2c2c2c !important;
  border: 2px solid #555 !important;
  color: #f0ead6 !important;
}
.dark-mode .delete-btn:hover:not(:disabled) {
  filter: brightness(90%) !important;
  box-shadow: var(--shadow-sm) !important;
}
.dark-mode #manualBtn.btn-primary,
.dark-mode #autosaveBtn.btn-primary {
  background-color: #5a5a5a !important;
}
.dark-mode #manualBtn.btn-primary:hover:not(:disabled),
.dark-mode #autosaveBtn.btn-primary:hover:not(:disabled) {
  filter: brightness(90%) !important;
  box-shadow: var(--shadow-sm) !important;
}
.dark-mode .progress-container {
  background: #2c2c2c;
  border: 1px solid #555;
}
.dark-mode .progress-bar {
  background-color: #f0ead6;
}
.dark-mode .modal-content {
  background-color: #1e1e1e !important;
  color: #f0ead6 !important;
}

/* ============================================
   Estilos para aislar el widget de Buy Me a Coffee
   ============================================ */
.widget-container {
  all: unset;
  display: block;
  font-family: sans-serif;
  color: initial;
  background: transparent;
}
.widget-container * {
  all: unset;
  display: revert;
  font-family: inherit;
  color: initial;
  background: transparent;
}

/* ============================================
   Estilos adicionales para el tema claro
   (Aplicados cuando no hay la clase .dark-mode)
   ============================================ */
body:not(.dark-mode) .timer-card,
body:not(.dark-mode) .block-editor,
body:not(.dark-mode) .block-item {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.1);
}
body:not(.dark-mode) .block-item.active {
  border-left: 4px solid var(--primary-500) !important;
  background: #fff !important;
}
