/* ==========================================================================
   1. RESET & BASE STYLES
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #667eea 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  overflow-x: hidden;
}

/* Animated background blur elements for depth */
body::before {
  content: "";
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 60%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
  animation: float 20s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(-20px, -20px) rotate(1deg); }
  66% { transform: translate(20px, -10px) rotate(-1deg); }
}

/* ==========================================================================
   2. LAYOUT & CONTAINER
   ========================================================================== */
.container {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  padding: 20px;
  border-radius: 28px;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Top highlight border for glassmorphism effect */
.container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  border-radius: 28px 28px 0 0;
}

.main-layout {
  display: grid;
  gap: 2rem;
}

/* ==========================================================================
   3. TYPOGRAPHY
   ========================================================================== */
h1 {
  text-align: center;
  color: #ffffff;
  font-size: 2.75rem;
  font-weight: 600;
  margin-bottom: 48px;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.8) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

label {
  display: block;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  margin-bottom: 8px;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   4. FORMS & INPUTS
   ========================================================================== */
.input-section {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-radius: 20px;
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: all 0.3s ease;
}

.input-section:hover {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.input-group {
  margin-bottom: 24px;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 16px 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 400;
  outline: none;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

input[type="text"]:focus,
input[type="number"]:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(0, 122, 255, 0.6);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1), 0 8px 16px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

input::placeholder {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 400;
}

.time-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ==========================================================================
   5. BUTTONS (GLOBAL & PRIMARY)
   ========================================================================== */
.btn {
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.8) 0%, rgba(88, 86, 214, 0.8) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 16px 32px;
  border-radius: 12px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 8px 16px rgba(0, 122, 255, 0.2);
  letter-spacing: -0.01em;
  margin-top: 8px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* Universal hover: brightens any background color/gradient by 15% */
.btn:hover {
  transform: translateY(-2px);
  -webkit-filter: brightness(1.15);
  filter: brightness(1.15);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn:active {
  transform: translateY(0) scale(0.96);
  box-shadow: 0 4px 8px rgba(0, 122, 255, 0.2);
}

/* Shine effect for main button */
.btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.6s ease;
}

.btn:hover::before {
  left: 100%;
}

/* Clear All Button (Danger variant) */
.clear-btn {
  background: #fb4141;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 69, 58, 0.3);
  padding: 12px 24px;
  border-radius: 12px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  margin-top: 16px;
  width: 100%;
  letter-spacing: -0.01em;
  position: relative;
  overflow: hidden;
}

.clear-btn:hover {
  background: #ff4d4d;
  border-color: rgba(255, 69, 58, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 69, 58, 0.3);
}

.clear-btn:active {
  transform: translateY(0) scale(0.96);
  box-shadow: 0 4px 8px rgba(255, 69, 58, 0.2);
}

.clear-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.6s ease;
}

.clear-btn:hover::before {
  left: 100%;
}

/* ==========================================================================
   6. TIMER SPECIFIC STYLES
   ========================================================================== */
.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 12px;
}

.toggle-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

.toggle-btn.active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.timer-display {
  font-size: 3rem;
  font-weight: 700;
  text-align: center;
  margin: 20px 0;
  font-variant-numeric: tabular-nums;
  color: white;
  text-shadow: 0 2px 10px rgba(69, 121, 255, 0.3);
}

.timer-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Timer control button color variants */
.btn-primary { background: #4579ff; color: white; }
.btn-warning { background: #f59e0b; color: white; }
.btn-success { background: #10b981; color: white; }
.btn-danger { background: #ef4444; color: white; }

/* ==========================================================================
   7. DISPLAY & LISTS
   ========================================================================== */
.total-section {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-radius: 20px;
  padding: 32px;
  margin-bottom: 24px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.total-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

.total-time {
  font-size: 3rem;
  font-weight: 300;
  background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.7) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.total-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.times-list {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  border-radius: 20px;
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  max-height: 400px;
  overflow-y: auto;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.times-list h3 {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 24px;
  text-align: center;
  letter-spacing: -0.01em;
}

.time-entry {
  position: relative;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.time-entry:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.time-entry-content {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 11px;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), background 0.3s ease;
  position: relative;
  z-index: 2;
}

.time-entry:hover .time-entry-content {
  background: rgba(255, 255, 255, 0.08);
}

.time-entry-content.is-dragging {
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5), 0 10px 15px -5px rgba(0, 0, 0, 0.2);
  z-index: 10;
  background: rgba(255, 255, 255, 0.06);
}

.time-entry-title {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 400;
  font-size: 1rem;
  flex-grow: 1;
  letter-spacing: -0.01em;
}

.time-entry-time {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  font-size: 1rem;
  margin-left: 16px;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.empty-state {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
  padding: 48px 24px;
  font-size: 1rem;
  font-weight: 400;
}

/* Custom Apple-style scrollbar */
.times-list::-webkit-scrollbar {
  width: 6px;
}

.times-list::-webkit-scrollbar-track {
  background: transparent;
}

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

.times-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   8. MODALS & ALERTS
   ========================================================================== */
.custom-alert {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.custom-alert.show {
  opacity: 1;
  visibility: visible;
}

.custom-alert-content {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  padding: 40px 32px 32px;
  max-width: 90%;
  width: 380px;
  text-align: center;
  color: #ffffff;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-alert.show .custom-alert-content {
  transform: scale(1);
}

.custom-alert-content::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  border-radius: 24px 24px 0 0;
}

.custom-alert-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
}

.custom-alert-content h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.custom-alert-content p {
  margin-bottom: 28px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.6;
  font-size: 1rem;
}

.custom-alert-buttons {
  display: flex;
  gap: 12px;
  flex-direction: column;
}

.custom-alert-buttons .btn {
  flex: 1;
  padding: 14px 24px;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-align: center;
  min-width: 80px;
  position: relative;
  overflow: hidden;
}

/* Confirm button (danger) inside modal */
.custom-alert-buttons .btn-confirm {
  background: linear-gradient(135deg, rgba(255, 69, 58, 0.9) 0%, rgba(200, 50, 40, 0.9) 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(255, 69, 58, 0.3);
}

.custom-alert-buttons .btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 69, 58, 0.4);
  background: linear-gradient(135deg, rgba(255, 69, 58, 1) 0%, rgba(200, 50, 40, 1) 100%);
}

.custom-alert-buttons .btn-confirm:active {
  transform: translateY(0) scale(0.96);
}

.custom-alert-buttons .btn-confirm::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.6s ease;
}

.custom-alert-buttons .btn-confirm:hover::before {
  left: 100%;
}

/* Cancel button (glassmorphism) inside modal */
.custom-alert-buttons .btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.custom-alert-buttons .btn-cancel:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.custom-alert-buttons .btn-cancel:active {
  transform: translateY(0) scale(0.96);
}

.custom-alert-buttons .btn-cancel::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.6s ease;
}

.custom-alert-buttons .btn-cancel:hover::before {
  left: 100%;
}

/* Standalone Alert OK Button */
.alert-btn {
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.8) 0%, rgba(88, 86, 214, 0.8) 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 100%;
  position: relative;
  overflow: hidden;
}

.alert-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 122, 255, 0.3);
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.9) 0%, rgba(88, 86, 214, 0.9) 100%);
  border-color: rgba(255, 255, 255, 0.3);
}

.alert-btn:active {
  transform: translateY(0) scale(0.96);
}

.alert-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.6s ease;
}

.alert-btn:hover::before {
  left: 100%;
}

body.modal-open {
  overflow: hidden;
}

/* ==========================================================================
   9. INLINE ACTIONS (Edit / Delete)
   ========================================================================== */
.edit-btn {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: #4f46e5;
  font-size: 18px;
  cursor: pointer;
  margin-right: 6px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.edit-btn:hover {
  border: 1px solid #4f46e5;
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  background: rgba(79, 70, 229, 0.1);
}

.edit-btn:active {
  transform: scale(0.95);
}

.delete-btn {
  background: #fb4141;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 69, 58, 0.3);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-btn:hover {
  border-color: rgba(255, 69, 58, 0.6);
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 69, 58, 0.3);
  background: #ff4d4d;
}

.delete-btn:active {
  transform: scale(0.95);
}

/* ==========================================================================
   10. DESKTOP & TABLET MEDIA QUERIES
   ========================================================================== */
@media (min-width: 576px) {
  body {
    padding: 20px;
  }
  
  .container {
    margin-top: 20px;
    width: 95%;
    border-radius: 28px;
  }
  
  .swipe-bg {
    display: none; /* Hide swipe backgrounds on desktop */
  }
}

@media (min-width: 576px) and (max-width: 768px) {
  h1 {
    font-size: 2.25rem;
    margin-bottom: 32px;
  }

  .input-section,
  .total-section,
  .times-list {
    padding: 24px;
  }

  .total-section {
    margin-bottom: 20px;
  }

  .total-time {
    font-size: 2.5rem;
  }
}

@media (min-width: 576px) and (max-width: 992px) {
  .main-layout {
    gap: 1rem;
  }
}

@media (min-width: 768px) {
  .main-layout {
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
  }
}

@media (min-width: 992px) {
  .container {
    padding: 48px;
    width: 90%;
    max-width: 1000px;
    margin-top: 40px;
  }
}