/* ============================================================
   TIMER STUDIO BUILDER — Professional Light Theme
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; }

body {
  background: #f5f6fa;
  color: #1e293b;
  font-family: 'Inter', sans-serif;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
  box-sizing: border-box;
}


/* ---- Page header ---- */
.builder-page-header {
  margin-bottom: 2rem;
}
.builder-page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.25rem;
}
.builder-page-header p {
  color: #64748b;
  margin: 0;
  font-size: 0.95rem;
}
.builder-page-header a { color: #3b82f6; text-decoration: none; }

/* ---- Two-column layout ---- */
.builder-layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  grid-template-areas: "controls preview";
  gap: 2rem;
  align-items: start;
  width: 100%;
}

.left-panel  { grid-area: controls; min-width: 0; }
.right-panel { grid-area: preview; min-width: 0; }

/* ---- Left panel — controls ---- */
.left-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.control-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.control-section h3 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}

.form-group {
  margin-bottom: 0.9rem;
}
.form-group:last-child { margin-bottom: 0; }

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: #f8fafc;
  border: 1.5px solid #d1d5db;
  color: #0f172a;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: block;
  min-height: 42px;
}
.form-control:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  background: #fff;
}

/* iOS date/time inputs need special treatment */
input[type="date"].form-control,
input[type="time"].form-control {
  -webkit-appearance: none;
  appearance: none;
  color: #374151;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1.2em;
  padding-right: 2rem;
  appearance: none;
}

/* ---- Theme/Layout chip selector ---- */
.theme-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.theme-card {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  transition: all 0.15s;
  user-select: none;
}
.theme-card:hover {
  border-color: #93c5fd;
  color: #2563eb;
  background: #eff6ff;
}
.theme-card input[type="radio"] { display: none; }
.theme-card:has(input:checked) {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #2563eb;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
/* Fallback for browsers without :has() */
.theme-card.active {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #2563eb;
}

/* ---- Checkbox toggle ---- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0;
  gap: 1rem;
}
.toggle-row label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  margin: 0;
  flex: 1;
  min-width: 0;
}
.toggle-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  appearance: none;
  -webkit-appearance: none;
  background: #cbd5e1;
  border-radius: 22px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.toggle-row input[type="checkbox"]:checked { background: #3b82f6; }
.toggle-row input[type="checkbox"]:checked::after { left: 18px; }

/* ---- Color Pickers ---- */
.color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.color-grid .form-group label {
  font-size: 0.7rem;
  margin-bottom: 0.25rem;
  display: block;
}
.color-input {
  width: 100%;
  height: 38px;
  padding: 4px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}

@media (max-width: 480px) {
  .color-grid {
    grid-template-columns: repeat(3, 1fr); /* 3 is still okay if small */
    gap: 0.5rem;
  }
}

.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}


/* ---- Color picker ---- */
input[type="color"].form-control {
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

/* ---- Right panel — preview ---- */
.right-panel {
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

.preview-box {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  position: relative;
}

/* Checkerboard shows through when bg is transparent */
.preview-box[data-transparent="true"] {
  background-image:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #f8fafc;
}

/* The actual timer render area */
#timer-preview {
  width: 100%;
  height: 320px;
}

/* Save button */
.left-panel .btn, 
.right-panel .btn,
#share-panel .btn,
.builder-layout .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.builder-layout .btn-primary,
#share-panel .btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  box-shadow: 0 2px 8px rgba(59,130,246,0.35);
  width: 100%;
}
.builder-layout .btn-primary:hover,
#share-panel .btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 4px 12px rgba(59,130,246,0.45);
  transform: translateY(-1px);
}

.builder-layout .btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1.5px solid #e2e8f0;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}
.btn-secondary:hover {
  background: #e2e8f0;
  color: #1e293b;
}

/* ---- Share Panel ---- */
#share-panel {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
#share-panel .success-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.copy-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}
.copy-row input {
  flex: 1;
  min-width: 0;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.78rem;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.6rem;
  height: 42px;
}
.copy-row .btn {
  width: auto;
  white-space: nowrap;
  padding: 0 1.25rem;
  height: 42px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .builder-layout {
    grid-template-columns: 1fr;
    grid-template-areas: "preview" "controls";
    gap: 1rem;
  }

  .right-panel { position: static; }

  #timer-preview { height: 220px; }

  .theme-chips { gap: 0.35rem; }

  .theme-card {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
  }

  .builder-page-header h1 { font-size: 1.4rem; }
  .control-section { padding: 1rem; }
}

@media (max-width: 480px) {
  #timer-preview { height: 180px; }
}
