/* Global Styling & Reset */
:root {
  --bg-color: #080b11;
  --panel-bg: rgba(17, 24, 39, 0.65);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  
  /* Status Colors */
  --accent-ready: #6366f1; /* Indigo */
  --accent-active: #10b981; /* Emerald Green */
  --accent-warning: #f59e0b; /* Amber */
  --accent-alarm: #ef4444; /* Red */
  
  --shadow-color: rgba(0, 0, 0, 0.4);
  
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  padding: 20px;
  position: relative;
}

/* Background Gradients and Ambient Glows */
.bg-gradient {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 30% 30%, #111424 0%, #070913 100%);
  z-index: -3;
}

.glow-sphere {
  position: fixed;
  width: 45vw;
  height: 45vw;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15;
  pointer-events: none;
  z-index: -2;
  transition: all 1s ease;
}

.glow-sphere.orange {
  top: -10%;
  right: -10%;
  background: radial-gradient(circle, var(--accent-active) 0%, transparent 70%);
}

.glow-sphere.blue {
  bottom: -15%;
  left: -10%;
  background: radial-gradient(circle, var(--accent-ready) 0%, transparent 70%);
}

/* Timer State Specific Body Glow Effects */
body.timer-ready .glow-sphere.orange {
  background: radial-gradient(circle, var(--accent-ready) 0%, transparent 70%);
}

body.timer-running .glow-sphere.orange {
  background: radial-gradient(circle, var(--accent-active) 0%, transparent 70%);
  opacity: 0.22;
}

body.timer-finished .glow-sphere.orange {
  background: radial-gradient(circle, var(--accent-alarm) 0%, transparent 70%);
  opacity: 0.3;
}

/* App Container Layout */
.app-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 1;
}

/* Premium Glassmorphic Cards */
.timer-card, .history-card {
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 32px 24px;
  box-shadow: 0 20px 40px var(--shadow-color);
  transition: transform 0.3s ease, border-color 0.5s ease;
}

.timer-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Card Header & Status Badge */
.card-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.app-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-primary);
  opacity: 0.9;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-ready);
  box-shadow: 0 0 10px var(--accent-ready);
  transition: all 0.3s ease;
}

/* Dynamic State Colors for Header */
body.timer-ready .status-dot {
  background-color: var(--accent-ready);
  box-shadow: 0 0 10px var(--accent-ready);
}
body.timer-ready .status-badge {
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.2);
}

body.timer-running .status-dot {
  background-color: var(--accent-active);
  box-shadow: 0 0 12px var(--accent-active);
  animation: pulse-dot 1.5s infinite alternate;
}
body.timer-running .status-badge {
  color: var(--text-primary);
  border-color: rgba(16, 185, 129, 0.2);
}

body.timer-finished .status-dot {
  background-color: var(--accent-alarm);
  box-shadow: 0 0 14px var(--accent-alarm);
  animation: pulse-dot 0.6s infinite alternate;
}
body.timer-finished .status-badge {
  color: var(--accent-alarm);
  border-color: rgba(239, 68, 68, 0.3);
  font-weight: 700;
}

@keyframes pulse-dot {
  from { opacity: 0.4; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1.1); }
}

/* Timer Display Section */
.timer-display-section {
  position: relative;
  margin-bottom: 24px;
}

.circle-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 260px;
  height: 260px;
}

.progress-ring {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

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

.progress-ring-fg {
  fill: transparent;
  stroke: var(--accent-ready);
  stroke-width: 8px;
  stroke-linecap: round;
  stroke-dasharray: 722.566;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.1s linear, stroke 0.5s ease;
  filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.4));
}

body.timer-ready #progress-bar {
  stroke: var(--accent-ready);
  filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.4));
}

body.timer-running #progress-bar {
  stroke: var(--accent-active);
  filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.5));
}

body.timer-finished #progress-bar {
  stroke: var(--accent-alarm);
  filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.6));
  animation: alarm-shake-bar 0.5s infinite;
}

@keyframes alarm-shake-bar {
  0% { transform: scale(1) rotate(-90deg); }
  50% { transform: scale(1.02) rotate(-90deg); }
  100% { transform: scale(1) rotate(-90deg); }
}

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

.time-text {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
}

body.timer-finished .time-text {
  animation: pulse-text 0.8s infinite alternate;
}

@keyframes pulse-text {
  from { color: var(--text-primary); text-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
  to { color: var(--accent-alarm); text-shadow: 0 0 20px rgba(239, 68, 68, 0.8); }
}

.total-label {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 6px;
}

/* Control Buttons styling */
.controls-section {
  display: flex;
  width: 100%;
  gap: 12px;
  margin-bottom: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-body);
}

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

.btn-primary {
  flex: 2;
  background-color: var(--accent-active);
  color: #042f1a;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
  background-color: #10c88b;
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  flex: 1;
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-secondary:active {
  background-color: rgba(255, 255, 255, 0.03);
}

/* Running state alterations */
body.timer-running .btn-primary {
  background-color: var(--accent-warning);
  color: #451a03;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

body.timer-running .btn-primary:hover {
  background-color: #fbbf24;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

body.timer-finished .btn-primary {
  background-color: var(--accent-alarm);
  color: #fef2f2;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

body.timer-finished .btn-primary:hover {
  background-color: #f87171;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Exercise Section */
.exercise-section {
  width: 100%;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.input-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: left;
}

.input-wrapper {
  display: flex;
  gap: 8px;
  width: 100%;
}

.workout-input {
  flex: 1;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: all 0.3s ease;
  outline: none;
}

.workout-input:focus {
  border-color: rgba(16, 185, 129, 0.5);
  background-color: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.15);
}

.workout-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.btn-small {
  padding: 0 16px;
  background-color: var(--accent-ready);
  color: #ffffff;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-small:hover {
  background-color: #4f46e5;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Category Chips Selector */
.category-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.chip {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-body);
  outline: none;
}

.chip:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Specific styling based on active category */
.chip[data-category="하체"].active {
  background-color: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border-color: #6366f1;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}
.chip[data-category="어깨"].active {
  background-color: rgba(6, 182, 212, 0.15);
  color: #67e8f9;
  border-color: #06b6d4;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}
.chip[data-category="가슴"].active {
  background-color: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}
.chip[data-category="등"].active {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fde047;
  border-color: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}
.chip[data-category="유산소"].active {
  background-color: rgba(236, 72, 153, 0.15);
  color: #fbcfe8;
  border-color: #ec4899;
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.2);
}

/* Category-specific Badges in History */
.badge-category {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-category.cat-하체 {
  background-color: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.badge-category.cat-어깨 {
  background-color: rgba(6, 182, 212, 0.12);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.25);
}
.badge-category.cat-가슴 {
  background-color: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.badge-category.cat-등 {
  background-color: rgba(245, 158, 11, 0.12);
  color: #fde047;
  border: 1px solid rgba(245, 158, 11, 0.25);
}
.badge-category.cat-유산소 {
  background-color: rgba(236, 72, 153, 0.12);
  color: #fbcfe8;
  border: 1px solid rgba(236, 72, 153, 0.25);
}

/* History Card */
.history-card {
  padding: 24px;
}

.history-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
  border-left: 3px solid var(--accent-ready);
  padding-left: 8px;
}

body.timer-running .history-title {
  border-left-color: var(--accent-active);
}

body.timer-finished .history-title {
  border-left-color: var(--accent-alarm);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom Scrollbar for history list */
.history-list::-webkit-scrollbar {
  width: 4px;
}

.history-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.history-empty {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.3);
  padding: 20px 0;
  line-height: 1.5;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  animation: slide-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.history-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-workout {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
}

.history-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.history-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--accent-active);
}

/* Vibrating Screen Alert during finished timer */
body.timer-finished .timer-card {
  animation: shake 0.4s infinite;
  border-color: rgba(239, 68, 68, 0.3);
}

@keyframes shake {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-0.5deg); }
  20% { transform: translate(-3px, 0px) rotate(0.5deg); }
  30% { transform: translate(0px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(0.5deg); }
  50% { transform: translate(-1px, 2px) rotate(-0.5deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(2px, 1px) rotate(-0.5deg); }
  80% { transform: translate(-1px, -1px) rotate(0.5deg); }
  90% { transform: translate(2px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-0.5deg); }
}
