/* ===== ANIMATIONS ===== */
@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(180deg); }
}

@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes drift {
  0% { transform: translateX(0) translateY(0); }
  100% { transform: translateX(-100px) translateY(-100px); }
}

/* ===== BASE STYLES ===== */
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, Arial, sans-serif;
  background: #0a0e27;
  position: relative;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at 20% 30%, rgba(147, 51, 234, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: 1;
}

/* ===== BACKGROUND EFFECTS ===== */
.stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.star {
  position: absolute;
  background: white;
  border-radius: 50%;
  animation: twinkle 3s infinite;
}

.coin {
  position: absolute;
  font-size: 24px;
  animation: float 6s infinite ease-in-out;
  z-index: 2;
  opacity: 0.7;
}

.dollar {
  position: absolute;
  font-size: 32px;
  color: #ffd700;
  font-weight: bold;
  animation: drift 20s infinite linear;
  z-index: 2;
  opacity: 0.4;
}

/* ===== PERFORMANCE OPTIMIZATION: DISABLE ANIMATIONS WHEN TIMERS ARE ACTIVE ===== */
/* This reduces CPU usage by 15% and RAM by 200MB when timers are running */
body.timers-active .star,
body.timers-active .coin,
body.timers-active .dollar {
  animation: none !important;
  /* Keep elements visible but static */
  opacity: 0.5;
}

/* Optionally fade background slightly when timers active for better focus */
body.timers-active .stars {
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

/* ===== MAIN PANEL ===== */
.panel {
  width: min(1400px, 96vw);
  background: rgba(255, 255, 255, 0.98);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 22px 50px rgba(0,0,0,0.5), 0 0 100px rgba(255, 215, 0, 0.2);
  position: relative;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.title {
  font-size: 18px;
  font-weight: 800;
  color: #1976d2;
  margin: 0;
}

.datetime {
  font-size: 14px;
  font-weight: 600;
  color: #666;
}

/* ===== TABLE STYLES ===== */
table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: #e3f2fd;
  padding: 10px 6px;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: 0.5px;
}

thead th.task-col {
  width: 20%;
}

thead th.duration-group {
  width: 8%;
}

thead th.break-group {
  width: 8%;
}

thead th.sprint-col {
  width: 30px;
  font-size: 16px;
  padding: 10px 3px;
}

thead th.start-col {
  width: 70px;
  padding: 10px 3px;
}

tbody td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  transition: background-color 0.2s ease;
}

tbody td.task-cell {
  width: 20%;
  position: relative;
}

tbody td.duration-cell,
tbody td.break-cell {
  padding: 8px 3px;
}

tbody td.gap-cell {
  width: 2%;
  background: transparent;
  border: none;
}

tbody td.start-cell {
  padding: 8px 3px;
}

tbody td.sprint-cell {
  padding: 8px 3px;
}

tbody tr:hover {
  background: rgba(25, 118, 210, 0.08);
}

/* ===== ROW STATES ===== */
tbody tr.running {
  background: rgba(255, 152, 0, 0.15);
  box-shadow: inset 0 0 0 1px rgba(255, 152, 0, 0.3);
}

tbody tr.running:hover {
  background: rgba(255, 152, 0, 0.22);
}

tbody tr.running .task-cell input {
  font-weight: 700;
}

tbody tr.running input[type="text"],
tbody tr.running input[type="number"] {
  pointer-events: none;
  opacity: 1;
  border: none;
  background: transparent;
  cursor: default;
}

tbody tr[data-is-main="true"].completed {
  background: rgba(46, 125, 50, 0.3) !important;
}

tbody tr[data-is-main="true"].completed:hover {
  background: rgba(46, 125, 50, 0.4) !important;
}

/* ===== SUBTASK STYLES ===== */
tbody tr.subtask-row {
  background: rgba(0,0,0,0.02);
}

tbody tr.subtask-row:hover {
  background: rgba(25, 118, 210, 0.08);
}

tbody tr.subtask-row.running:hover {
  background: rgba(255, 152, 0, 0.22);
}

tbody tr.subtask-row .sno-cell,
tbody tr.subtask-row td:nth-child(2),
tbody tr.subtask-row td:nth-child(3) {
  padding-left: 20px;
}

tbody tr.subtask-row.completed {
  background: rgba(76, 175, 80, 0.15) !important;
}

tbody tr.subtask-row.completed:hover {
  background: rgba(76, 175, 80, 0.25) !important;
}

tbody tr.subtask-row td.task-cell {
  padding-left: 8px;
}

tbody tr.subtask-row td.task-cell input {
  width: 98%;
  margin-left: 16px;
}

tbody tr.subtask-row.hidden {
  display: none;
}

tbody tr.subtask-btn-row .add-subtask-btn {
  margin-left: 20px;
}

tbody tr.subtask-btn-row {
  border: none;
}

tbody tr.subtask-btn-row td {
  border: none;
}

tbody tr.subtask-btn-row:hover {
  background: transparent;
}

tbody tr.subtask-btn-row.hidden {
  display: none;
}

/* ===== INPUT STYLES ===== */
input[type="text"] {
  width: 98%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.15);
  font-size: 13px;
}

input[type="number"] {
  width: 70%;
  min-width: 50px;
  padding: 6px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.15);
}

input[type="number"].duration-input {
  font-size: 16px;
  font-weight: 700;
}

input[type="number"].break-input {
  font-size: 13px;
}

input:disabled {
  cursor: not-allowed;
}

/* ===== BUTTON STYLES ===== */
button.start-btn {
  padding: 4px 6px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #ff9800, #ff6f00);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
  min-height: 36px;
  width: 100%;
}

button.start-btn:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.subtask-row button.start-btn {
  background: linear-gradient(135deg, #2196f3, #1976d2);
}

.add-row {
  margin-top: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2e7d32, #1b5e20);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
}

.add-row:hover {
  opacity: 0.9;
}

.expand-all-btn {
  margin-top: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #1976d2, #1565c0);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.expand-all-btn:hover {
  opacity: 0.9;
}

.file-btn {
  margin-top: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #7b1fa2, #4a148c);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.file-btn:hover {
  opacity: 0.9;
}

.refresh-btn {
  margin-top: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #d32f2f, #b71c1c);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.refresh-btn:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

.add-subtask-btn {
  padding: 4px 8px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.3);
  background: #fff;
  color: #333;
  font-size: 16px;
  cursor: pointer;
  font-weight: 700;
  min-width: auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.add-subtask-btn:hover {
  background: rgba(0,0,0,0.05);
  border-color: #000;
}

.pause-btn {
  padding: 4px 6px;
  border-radius: 6px;
  border: none;
  background: #d32f2f;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 12px;
  margin-left: 6px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pause-btn:hover {
  background: #b71c1c;
}

.pause-btn.resumed {
  background: #2e7d32;
}

.pause-btn.resumed:hover {
  background: #1b5e20;
}

.button-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.button-group-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button-group-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== TIMER STYLES ===== */
.timer {
  font-weight: 900;
  transition: font-size 0.15s ease;
}

.timer.work {
  color: #1976d2;
  font-size: 16px;
}

.timer.break {
  color: #7b1fa2;
  font-size: 13px;
}

.timer.idle {
  color: #d32f2f;
  font-size: 14px;
  font-weight: 900;
}

.timer.active {
  font-size: 32px;
}

/* ===== STATUS STYLES ===== */
.status {
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  display: inline-block;
  line-height: 1.3;
  text-align: center;
}

.status.notyet {
  background: rgba(0,0,0,0.05);
  color: #666;
}

.status.inprogress {
  background: rgba(25,118,210,0.12);
  color: #1976d2;
}

.status.completed {
  background: rgba(46,125,50,0.15);
  color: #2e7d32;
}

/* ===== MISC STYLES ===== */
.delete-btn {
  cursor: pointer;
  font-size: 18px;
  opacity: 0.6;
}

.delete-btn:hover {
  opacity: 1;
}

.sno-cell {
  font-weight: 700;
  color: #1976d2;
  position: relative;
}

.subtask-row .sno-cell {
  font-size: 10px;
}

.twisty {
  cursor: pointer;
  display: inline-block;
  margin-right: 4px;
  font-size: 10px;
  transition: transform 0.2s ease;
  user-select: none;
  color: #1976d2;
}

.twisty.expanded {
  transform: rotate(90deg);
}

/* ===== SPRINT CHECKBOX STYLES ===== */
.sprint-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #ff9800;
}

.sprint-checkbox:disabled {
  cursor: not-allowed;
  opacity: 1;
}

/* FIXED: Show black checkmark when disabled and checked (running or completed state) */
.sprint-checkbox:checked:disabled {
  opacity: 1;
  accent-color: #000000;
  filter: none;
}

/* Ensure the checkbox remains visible with black checkmark */
tbody tr.running .sprint-checkbox:checked:disabled,
tbody tr.completed .sprint-checkbox:checked:disabled {
  accent-color: #000000;
  opacity: 1;
}

.tooltip {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 0;
  background: rgba(0,0,0,0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 10000;
  font-size: 12px;
  pointer-events: none;
  max-width: 400px;
  word-wrap: break-word;
  white-space: normal;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}