/* Design Tokens & Custom CSS Properties */
:root {
  --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-timer: 'JetBrains Mono', monospace;

  /* Colors */
  --bg-main: #09090e;
  --panel-bg: rgba(18, 18, 26, 0.65);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-focus: rgba(0, 212, 255, 0.3);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #6b7280;

  --accent-cyan: #00d4ff;
  --accent-cyan-glow: rgba(0, 212, 255, 0.4);
  --accent-teal: #10b981;
  --accent-teal-glow: rgba(16, 185, 129, 0.4);
  --accent-tomato: #ff4757;
  --accent-tomato-glow: rgba(255, 71, 87, 0.4);
  --accent-orange: #f97316;
  --accent-orange-glow: rgba(249, 115, 22, 0.4);

  --btn-primary-bg: rgba(0, 212, 255, 0.15);
  --btn-primary-border: rgba(0, 212, 255, 0.3);
  --btn-primary-text: #00d4ff;

  --btn-secondary-bg: rgba(255, 255, 255, 0.05);
  --btn-secondary-border: rgba(255, 255, 255, 0.1);
  --btn-secondary-text: #f3f4f6;

  --btn-danger-bg: rgba(255, 71, 87, 0.1);
  --btn-danger-border: rgba(255, 71, 87, 0.25);
  --btn-danger-text: #ff4757;

  /* Timing Values */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden; /* Prevent page from scrolling on desktop */
  position: relative;
  padding: 20px;
}

/* Moving background glow effects */
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.35;
  pointer-events: none;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.bg-glow-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--accent-cyan) 0%, transparent 70%);
  top: -10%;
  left: -10%;
  animation: floatGlow 15s infinite alternate ease-in-out;
}

.bg-glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-orange) 0%, transparent 70%);
  bottom: -15%;
  right: -10%;
  animation: floatGlow2 20s infinite alternate ease-in-out;
}

@keyframes floatGlow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(80px, 50px) scale(1.1); }
}

@keyframes floatGlow2 {
  0% { transform: translate(0, 0) scale(1.1); }
  100% { transform: translate(-100px, -60px) scale(0.9); }
}

/* Glassmorphic Container */
.app-container {
  width: 100%;
  max-width: 480px;
  background: var(--panel-bg);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 30px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 25px;
  z-index: 10;
}

/* Header Styles */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 24px;
  height: 24px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 5px var(--accent-cyan-glow));
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-accent {
  font-weight: 300;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Tab Bar */
.tab-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 5px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-normal);
}

.tab-icon {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-normal);
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn:hover .tab-icon {
  transform: translateY(-2px);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Main Display Panels */
.tab-panel {
  display: none;
  animation: fadeIn var(--transition-normal) forwards;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Display & Timer Digits */
.display-container {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.02);
  border-radius: 18px;
  padding: 25px 15px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.timer-digits {
  font-family: var(--font-timer);
  font-size: 3.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent-cyan);
  text-shadow: 0 0 20px var(--accent-cyan-glow);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  justify-content: center;
}

.ms-digits {
  font-size: 1.8rem;
  color: rgba(0, 212, 255, 0.7);
  font-weight: 400;
}

/* Circular Visual Timer (Timer & Pomodoro) */
.timer-visual-container {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.progress-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.03);
  stroke-width: 8px;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accent-teal);
  stroke-width: 8px;
  stroke-linecap: round;
  stroke-dasharray: 628.3; /* 2 * PI * r (r=100) */
  stroke-dashoffset: 628.3;
  transition: stroke-dashoffset 0.2s linear, stroke 0.3s ease;
  filter: drop-shadow(0 0 6px var(--accent-teal-glow));
}

.pomo-fill {
  stroke: var(--accent-orange);
  filter: drop-shadow(0 0 6px var(--accent-orange-glow));
}

.timer-visual-content {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.timer-visual-content .timer-digits {
  font-size: 2.3rem;
  color: var(--text-main);
  text-shadow: none;
}

/* Control Buttons Grid */
.controls-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
}

.btn {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 20px;
  border-radius: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
}

.btn-primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-border);
  color: var(--btn-primary-text);
  box-shadow: 0 4px 15px rgba(0, 212, 255, 0.1);
}

.btn-primary:hover:not(:disabled) {
  background: rgba(0, 212, 255, 0.25);
  border-color: var(--accent-cyan);
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.25);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
  color: var(--btn-secondary-text);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--btn-danger-bg);
  border-color: var(--btn-danger-border);
  color: var(--btn-danger-text);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 71, 87, 0.2);
  border-color: var(--accent-tomato);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Stopwatch Laps Layout */
.laps-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.laps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
}

.laps-header h3 {
  font-weight: 600;
  color: var(--text-main);
}

.btn-text-action {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.btn-text-action:hover {
  opacity: 0.8;
}

.action-icon {
  width: 14px;
  height: 14px;
}

.table-wrapper {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.1);
}

.laps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.laps-table th, .laps-table td {
  padding: 10px 14px;
  text-align: left;
}

.laps-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 500;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--panel-border);
  z-index: 1;
}

.laps-table tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.laps-table tr:last-child {
  border-bottom: none;
}

.laps-table tbody td {
  font-family: var(--font-timer);
  color: var(--text-main);
}

.no-laps-row td {
  font-family: var(--font-ui) !important;
  color: var(--text-dark) !important;
  text-align: center;
  padding: 25px 0;
}

.lap-row-fastest td {
  color: #10b981 !important;
}

.lap-row-slowest td {
  color: #ef4444 !important;
}

/* Time Setup Pickers */
.setup-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.setup-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.picker-row {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 8px 16px;
  transition: border-color var(--transition-fast);
}

.picker-row:focus-within {
  border-color: var(--panel-border-focus);
}

.picker-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.picker-group input {
  background: transparent;
  border: none;
  font-family: var(--font-timer);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-main);
  width: 40px;
  text-align: center;
  outline: none;
}

.picker-group input::-webkit-outer-spin-button,
.picker-group input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.picker-group input[type=number] {
  -moz-appearance: textfield;
}

.picker-group span {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-right: 4px;
}

.picker-colon {
  font-size: 1.5rem;
  color: var(--text-dark);
  margin: 0 4px;
  font-family: var(--font-timer);
}

/* Presets Row */
.presets-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Pomodoro Options */
.pomo-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.option-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  padding: 8px 10px;
  border-radius: 10px;
  text-align: center;
}

.option-field label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.option-field input {
  background: transparent;
  border: none;
  font-family: var(--font-timer);
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  outline: none;
}

.pomo-status-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.pomo-work {
  background: rgba(249, 115, 22, 0.1);
  color: var(--accent-orange);
  border: 1px solid rgba(249, 115, 22, 0.2);
}

.pomo-break {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-teal);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.pomo-cycle-dots {
  display: flex;
  gap: 6px;
}

.cycle-dot {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.cycle-dot.active {
  background: var(--accent-orange);
  box-shadow: 0 0 8px var(--accent-orange-glow);
}

.cycle-dot.completed {
  background: var(--accent-teal);
  box-shadow: 0 0 8px var(--accent-teal-glow);
}

/* Modals & Popups */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 90%;
  max-width: 400px;
  background: rgba(20, 20, 30, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn var(--transition-normal) forwards;
}

@keyframes modalSlideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.close-btn:hover {
  color: var(--text-main);
}

.close-btn svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.shortcut-item kbd {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--font-timer);
  font-size: 0.8rem;
  color: var(--accent-cyan);
}

.shortcut-item span {
  color: var(--text-muted);
}

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

/* Enhanced Mobile Responsive Adjustments */
@media (max-width: 480px) {
  body {
    padding: 8px;
    align-items: flex-start;
    padding-top: 20px;
    padding-bottom: 20px;
    overflow-y: auto; /* Allow scrolling if container overflows on mobile */
  }
  
  .app-container {
    padding: clamp(14px, 4vw, 20px);
    gap: clamp(14px, 4vw, 20px);
    border-radius: 18px;
    width: 100%;
    max-width: 100%;
  }

  .tab-bar {
    padding: 3px;
    border-radius: 12px;
  }

  .tab-btn {
    padding: 8px 2px;
    font-size: 0.8rem;
  }

  .tab-icon {
    width: 16px;
    height: 16px;
  }

  .timer-digits {
    font-size: clamp(2.2rem, 9vw, 2.7rem);
  }
  
  .ms-digits {
    font-size: clamp(1.2rem, 5vw, 1.5rem);
  }

  /* Circular visual countdown elements responsive sizing */
  .timer-visual-container {
    width: clamp(160px, 45vw, 190px);
    height: clamp(160px, 45vw, 190px);
  }

  .timer-visual-content .timer-digits {
    font-size: clamp(1.7rem, 6.5vw, 2rem);
  }

  /* Compact button styling for smaller screen constraints */
  .btn {
    padding: 12px 16px;
    font-size: 0.95rem;
    border-radius: 11px;
  }

  /* Laps details layout fits beautifully */
  .laps-table th, .laps-table td {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  /* Mobile dialog layout bottom drawer animation */
  .modal-backdrop {
    align-items: flex-end;
  }

  .modal-card {
    width: 100%;
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    margin: 0;
    box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.4);
    animation: bottomSheetSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  @keyframes bottomSheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* Extra Compact Layout for Devices Under 360px (e.g. iPhone SE) */
@media (max-width: 360px) {
  .app-container {
    padding: 12px;
    gap: 12px;
  }

  .tab-btn {
    font-size: 0.72rem;
  }

  .timer-visual-container {
    width: 140px;
    height: 140px;
  }

  .timer-visual-content .timer-digits {
    font-size: 1.5rem;
  }

  .presets-row {
    gap: 6px;
  }

  .preset-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    flex: 1 1 40%;
    text-align: center;
  }

  .pomo-options {
    gap: 6px;
  }

  .option-field {
    padding: 6px 4px;
    border-radius: 8px;
  }

  .option-field label {
    font-size: 0.7rem;
  }

  .option-field input {
    font-size: 0.95rem;
  }

  .picker-row {
    padding: 6px 12px;
  }

  .picker-group input {
    font-size: 1.3rem;
    width: 34px;
  }

  .picker-colon {
    font-size: 1.3rem;
  }
}

/* Hide all visual scrollbars for a premium, clean look */
::-webkit-scrollbar {
  display: none;
}
* {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}