/* ===== MAIN STYLES - Solara Dashboard ===== */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  position: relative;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
  user-select: none;
}

/* ===== BACKGROUND ===== */
#background-container {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#background-image,
#background-image-next {
  position: absolute;
  /* Extend beyond edges so zoom doesn't show borders */
  inset: -20px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity 1.5s ease;
  /* 3D Ken Burns slow zoom from center */
  animation: kenBurnsZoom 25s ease-in-out infinite alternate;
  transform-origin: center center;
  will-change: transform;
}

#background-image-next {
  opacity: 0;
  /* Offset the animation so transitions look smooth */
  animation-delay: -12s;
}

#background-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0,0,0,0.2) 0%,
    rgba(0,0,0,0.05) 30%,
    rgba(0,0,0,0.05) 70%,
    rgba(0,0,0,0.4) 100%
  );
  pointer-events: none;
}

/* ===== LAYOUT ===== */
#top-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  flex-shrink: 0;
}

.top-left, .top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-center {
  display: flex;
  align-items: center;
}

#main-content {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 24px;
  overflow: hidden;
  min-height: 0;
}

#bottom-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 16px 24px;
  flex-shrink: 0;
}

.bottom-left, .bottom-center, .bottom-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
}

.bottom-right {
  position: relative;
  z-index: 10;
}

.bottom-center {
  flex: 1;
  justify-content: center;
  text-align: center;
  padding: 0 20px;
}

/* ===== BUTTONS ===== */
.icon-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  opacity: 0.7;
  font-size: 13px;
  font-family: inherit;
  position: relative;
}

.icon-btn:hover {
  opacity: 1;
  background: var(--bg-glass);
}

/* ===== ICON-BUTTON HOVER TOOLTIP =====
   Custom hover tooltip that replaces the native browser one. We read
   the label from a dedicated `data-tooltip` attribute instead of the
   `title` attribute so the browser never renders its own ugly delayed
   tooltip on top of ours. app.js mirrors title → data-tooltip at init
   so legacy markup keeps working.

   Direction defaults to below the button (top-bar placement). For
   buttons in the bottom bar, add `data-tooltip-dir="up"` to flip the
   anchor upwards so the tooltip doesn't get clipped by the viewport
   bottom edge. */
[data-tooltip] {
  position: relative;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1000;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  opacity: 0;
  animation: icon-tooltip-in 0.15s ease-out 0.25s forwards;
}
/* Upward-opening variant used by bottom-bar buttons. */
[data-tooltip][data-tooltip-dir="up"]:hover::after,
[data-tooltip][data-tooltip-dir="up"]:focus-visible::after {
  top: auto;
  bottom: calc(100% + 6px);
}
@keyframes icon-tooltip-in { to { opacity: 1; } }

/* Top-bar buttons remain semantically grouped via HTML order only —
   no visible separators. Uniform 8 px gap from .top-left. */

.icon-btn-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s ease;
  opacity: 0.6;
}

.icon-btn-sm:hover {
  opacity: 1;
  background: var(--bg-secondary);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg-glass);
}

/* ===== PANELS ===== */
.side-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 320px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.side-panel.visible {
  transform: translateX(0);
}

.side-panel-left {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 360px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.side-panel-left.visible {
  transform: translateX(0);
}

.overlay-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 500px;
  max-height: 80vh;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.overlay-panel.visible {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}

.dropdown-panel {
  position: fixed;
  top: 60px;
  left: 120px;
  width: 300px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-panel.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal.visible {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 400px;
  max-width: 90vw;
}

.modal-content h3 {
  margin-bottom: 16px;
  font-size: 18px;
}

.modal-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s ease;
}

.modal-input:focus {
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ===== UTILITY ===== */
.hidden {
  display: none !important;
}

/* Panels use hidden differently - they need transitions */
.side-panel.hidden,
.side-panel-left.hidden,
.overlay-panel.hidden,
.dropdown-panel.hidden,
.modal.hidden,
.search-overlay.hidden,
.breathing-overlay.hidden {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
}

.side-panel.hidden { transform: translateX(100%); }
.side-panel-left.hidden { transform: translateX(-100%); }
.overlay-panel.hidden { opacity: 0; pointer-events: none; }
.dropdown-panel.hidden { opacity: 0; pointer-events: none; }
.modal.hidden { opacity: 0; pointer-events: none; }
.search-overlay.hidden { opacity: 0; pointer-events: none; }
.breathing-overlay.hidden { display: none !important; }

.text-muted {
  color: var(--text-secondary);
}

.text-accent {
  color: var(--accent);
}

/* ===== FOCUS MODE ===== */
body.focus-mode #top-bar .top-left,
body.focus-mode #bottom-bar .bottom-left,
body.focus-mode #bottom-bar .bottom-right,
body.focus-mode #greeting-widget,
body.focus-mode #focus-widget {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

body.focus-mode #quote-widget {
  font-style: italic;
  color: var(--accent);
}

/* ===== POMODORO / BREATHING STATUS BAR ===== */
#pomodoro-status,
#breathing-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  /* Pills contain live countdowns ("Odaklanıyor · 24:35") — tabular
     numerals keep the digits from reflowing the whole pill each tick. */
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}
#pomodoro-status-text,
#breathing-status-text {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  white-space: nowrap;
}

#pomodoro-status .status-dot,
#breathing-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease infinite;
}

/* Two status pills can be visible at once (pomodoro + breathing), so
   top-center needs a gap. The pills also need to sit above background
   video overlays; the top bar already provides z-index context. */
.top-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== POMODORO ACTIVE: shrink clock, keep greeting, expand pomodoro =====
   On entering pomodoro mode, the clock smoothly morphs to a small size
   and sits at the top of the main column; the greeting stays at normal
   size; the pomodoro widget fades in below. All three elements use the
   same cubic-bezier easing so the transition reads as one coordinated
   morph rather than three separate animations. */
/* Pomodoro active: pull everything toward the top so the small clock,
   the hidden greeting and the (now larger) pomodoro widget sit in a
   tight column instead of floating in centered whitespace. Without
   this override flex center puts ~200px of empty space above AND
   below the group, which the user perceives as wasted space. */
body.pomodoro-active #main-content {
  justify-content: flex-start;
  padding-top: clamp(32px, 6vh, 72px);
  gap: clamp(14px, 2.2vh, 28px);
}

/* Don't scale the whole clock-widget — that would shrink the date and
   workday label along with the time, making them unreadable (~8px). We
   instead override font-size on each child independently so the time
   shrinks aggressively while the date and workday line stay legible. */
body.pomodoro-active #clock-widget {
  opacity: 0.95;
}
body.pomodoro-active .clock-time {
  font-size: clamp(38px, 5.5vw, 68px);
  letter-spacing: -1px;
}
body.pomodoro-active .clock-seconds {
  font-size: clamp(14px, 1.8vw, 22px);
}
body.pomodoro-active .clock-date {
  font-size: clamp(12px, 1.4vw, 15px);
  opacity: 0.75;
  margin-top: 4px;
  letter-spacing: 0.6px;
}
body.pomodoro-active .workday-progress {
  font-size: 11px;
  opacity: 0.65;
  transform: scale(0.88);
  transform-origin: top center;
  max-width: 220px;
}

body.pomodoro-active #greeting-widget {
  opacity: 0;
  transform: scale(0.9) translateY(-8px);
  pointer-events: none;
  max-height: 0;
  margin: 0;
  overflow: hidden;
}

body.pomodoro-active #focus-widget {
  display: none !important;
}

body.pomodoro-active .pomodoro-ring-wrap {
  width: clamp(220px, 44vh, 400px);
  height: clamp(220px, 44vh, 400px);
}

body.pomodoro-active .pomodoro-time {
  font-size: clamp(48px, 11vh, 100px);
}

body.pomodoro-active .pomodoro-tab {
  font-size: clamp(12px, 1.8vh, 16px);
  padding: clamp(4px, 1vh, 8px) clamp(14px, 2.4vh, 24px);
}

body.pomodoro-active .pomodoro-focus-text {
  font-size: clamp(13px, 2.2vh, 20px);
}

body.pomodoro-active .pomodoro-play-btn {
  width: clamp(52px, 7.6vh, 72px);
  height: clamp(52px, 7.6vh, 72px);
}

body.pomodoro-active .pomodoro-controls {
  gap: clamp(12px, 2.4vh, 22px);
}

body.pomodoro-active .pomodoro-layout {
  gap: clamp(24px, 4.8vh, 44px);
}

body.pomodoro-active .pomodoro-skip-btn svg {
  width: clamp(20px, 3vh, 28px);
  height: clamp(20px, 3vh, 28px);
}

body.pomodoro-active .pomodoro-play-btn svg {
  width: clamp(30px, 4.2vh, 38px);
  height: clamp(30px, 4.2vh, 38px);
}

body.pomodoro-active .pomodoro-right {
  gap: clamp(10px, 1.8vh, 16px);
}

/* Smooth coordinated morph when entering/leaving pomodoro mode.
   Each clock sub-element morphs its own font-size, the greeting
   slides, and the whole layout settles with matching easing so it
   reads as one continuous motion.
   cubic-bezier(0.22, 1, 0.36, 1) is easeOutQuint — fast start with a
   long graceful settle, which feels like "morphing into place". */
#clock-widget,
#greeting-widget {
  transition:
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    margin 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    max-height 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform, margin, opacity, max-height;
}
.clock-time,
.clock-seconds,
.clock-date,
.workday-progress {
  transition:
    font-size 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    margin 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    letter-spacing 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Status pills also morph-fade when toggled — the .hidden class adds
   display:none which disables the transition, so we animate via a
   .visible-ish state by also matching on the not-hidden selector. */
#pomodoro-status,
#breathing-status {
  transition:
    background 0.15s ease,
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Status pills are clickable: a soft fallback that expands the full UI
   if the user misses the dedicated maximize/stop icon buttons. */
#pomodoro-status,
#breathing-status {
  cursor: pointer;
  transition: background 0.15s ease;
}
#pomodoro-status:hover,
#breathing-status:hover {
  background: var(--bg-glass-hover, rgba(255,255,255,0.14));
}
#pomodoro-status .icon-btn-sm,
#breathing-status .icon-btn-sm {
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
#pomodoro-status .icon-btn-sm:hover,
#breathing-status .icon-btn-sm:hover {
  opacity: 1;
  transform: scale(1.08);
}

/* Emphasise the pomodoro minimize icon so users can actually find it.
   Previously it shared the subtle opacity of the skip/breathing buttons
   and users reported they couldn't locate the control. */
.pomodoro-minimize-btn {
  opacity: 0.9 !important;
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 50% !important;
}
.pomodoro-minimize-btn:hover {
  background: rgba(255,255,255,0.14) !important;
  border-color: rgba(255,255,255,0.25) !important;
}

/* ===== RESPONSIVE ===== */

/* Tablet / Nest Hub Max (≤1024px) */
@media (max-width: 1024px) {
  #top-bar { padding: 8px 12px; gap: 6px; }
  #top-bar .icon-btn { width: 28px; height: 28px; }
  #top-bar .icon-btn svg { width: 16px; height: 16px; }
  #bottom-bar { padding: 8px 12px; }
}

/* Small tablet / Nest Hub (≤800px) */
@media (max-width: 800px) {
  .side-panel, .side-panel-left { width: 100%; }
  .overlay-panel { width: 92vw; max-width: 92vw; }
  #top-bar { flex-wrap: wrap; padding: 6px 10px; gap: 4px; }
  #top-bar .top-left { gap: 2px; }
  #top-bar .top-right { gap: 4px; }
  #top-bar .icon-btn { width: 26px; height: 26px; padding: 3px; }
  #bottom-bar { padding: 6px 10px; }
  #main-content { padding: 0 12px; }
}

/* Phone landscape / small Nest Hub (≤600px) */
@media (max-width: 600px) {
  #top-bar { padding: 4px 8px; }
  #top-bar .top-left,
  #top-bar .top-right { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  #top-bar .icon-btn { width: 24px; height: 24px; min-width: 24px; }
  #top-bar .icon-btn svg { width: 14px; height: 14px; }
  .overlay-panel { width: 100vw; max-width: 100vw; border-radius: 0; }
  .side-panel, .side-panel-left { width: 100vw; }
  #main-content { padding: 0 8px; }
  #bottom-bar { gap: 8px; }
  .topbar-dropdown { width: 90vw !important; max-width: 90vw !important; }
}

/* Short viewport (Nest Hub 600px height) */
@media (max-height: 650px) {
  #main-content { gap: 2px; }
  #top-bar { padding: 4px 8px; }
  #bottom-bar { padding: 4px 8px; }
}
