/* =========================
   FocusFlow CSS
   ========================= */
:root {
  --bg-dark: #020617;
  --bg-light: #f8fafc;
  --card-dark: #0f172a;
  --card-light: #ffffff;
  --text-dark: #e5e7eb;
  --text-light: #020617;
  --primary: #38bdf8;
  --accent: #10b981;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-dark);
  transition: background-color 0.3s, color 0.3s;
  font-size: 14px;
}

body.light {
  background-color: var(--bg-light);
  color: var(--text-light);
}

.header {
  text-align: center;
  padding: 0.7rem 0.3rem;
}

.header h1 {
  font-size: 1.8rem;
  margin-bottom: 0.15rem;
}

.home-button {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background-color: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.3s, transform 0.3s, box-shadow 0.3s;
}

.home-button:hover {
  background-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.home-button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#quote {
  font-size: 0.8rem;
  opacity: 0.85;
}

.theme-toggle {
  position: fixed;
  top: 0.5rem;
  right: 0.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.3s, box-shadow 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

.theme-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app {
  max-width: 1400px;
  margin: auto;
  padding: 1rem 0.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-right: 20px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.form-row label {
  font-weight: 600;
  font-size: 0.85rem;
}

.card {
  background-color: var(--card-dark);
  padding: 0.8rem;
  border-radius: 0.8rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transition: background-color 0.3s;
}

body.light .card {
  background-color: var(--card-light);
}

.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.dashboard-collapse-controls {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
}

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  color: inherit;
  padding: 0;
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: left;
  border-radius: 0;
}

.section-toggle:hover {
  transform: none;
  box-shadow: none;
  background: transparent;
}

.dashboard-section.collapsed > :not(.section-toggle) {
  display: none;
}

.dashboard-section.collapsed .collapse-indicator {
  transform: rotate(-90deg);
}

.card h3 {
  font-size: 0.9rem;
  margin: 0.5rem 0 0.3rem 0;
}

input, textarea, select, button {
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  padding: 0.4rem;
}

input, textarea, select {
  width: 100%;
  border-radius: 0.5rem;
  border: 2px solid #ccc;
  transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

body.light input:focus, body.light textarea:focus, body.light select:focus {
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

textarea {
  min-height: 60px;
  resize: vertical;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  background-color: var(--primary);
  color: #fff;
  font-weight: 600;
  transition: all 0.3s ease;
  font-size: 0.85rem;
}

.button-link {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background-color: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  text-align: center;
  transition: all 0.3s ease;
}

.button-link:hover {
  background-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

button:hover:not(:disabled) {
  background-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
}

.btn-delete {
  background-color: transparent;
  color: #ef4444;
  padding: 0.25rem 0.5rem;
  font-size: 1rem;
  border-radius: 0.5rem;
}

.btn-delete:hover {
  background-color: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.timer {
  font-size: 1.8rem;
  text-align: center;
  margin: 0.5rem 0;
  font-weight: bold;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

li {
  background-color: rgba(231, 18, 18, 0.25);
  padding: 0.2rem;
  border-radius: 0.4rem;
  margin-bottom: 0.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.75rem;
}

body.light li {
  background-color: #e5e7eb;
}

li button {
  margin-left: 0.5rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.9rem;
}

#calendar {
  display: block;
  width: 100%;
  /* inner elements (.calendar-weekdays, .calendar-grid) handle layout */
}

#calendar span {
  display: inline-block;
  width: 26px;
  height: 26px;
  text-align: center;
  line-height: 26px;
  border-radius: 4px;
  font-size: 0.75rem;
}

#calendar span:nth-child(n+1) {
  background-color: rgba(255,255,255,0.1);
}

/* Month title styling inside header */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background-color: rgba(42, 157, 113, 0); /* slightly brightened greenish background */
  border-radius: 0.5rem;
}

.calendar-header .month-title {
  flex: 1 1 auto;
  display: block !important;
  text-align: center;
  background: rgba(1, 3, 2, 0.35) !important;
  color: #fff;
  font-weight: 700;
  font-size: 1.5rem !important;
  padding: 0.6rem 0.8rem;
  margin: 0 4.5rem;
  border-radius: 9.6rem;
  box-shadow: 0 8px 20px rgba(251, 0, 0, 0.15) !important;
}

body.light .calendar-header .month-title {
  background: rgba(16, 185, 129, 0.25);
  color: #1f2937;
}

/* ========================= 
   Calendar Styling
   ========================= */
.calendar-day {
  font-size: 0.7rem;
  padding: 0.2rem;
  border-radius: 0.3rem;
  background-color: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  text-align: center;
  font-weight: 500;
}

.calendar-day:hover {
  background-color: rgba(56, 189, 248, 0.2);
  transform: scale(1.05);
}

.calendar-today {
  background-color: var(--accent);
  color: #fff;
  font-weight: bold;
  border-color: var(--accent);
}

.calendar-has-events {
  border-color: var(--primary);
  background-color: rgba(56, 189, 248, 0.15);
  position: relative;
}

.calendar-has-events::after {
  content: '•';
  position: absolute;
  bottom: 2px;
  right: 4px;
  color: var(--primary);
  font-weight: bold;
}

body.light .calendar-day {
  background-color: rgba(0, 0, 0, 0.03);
}

textarea#noteInput {
  min-height: 40px;
}

#eventDesc {
  min-height: 30px !important;
}

input[type="number"] {
  max-width: 100px;
  margin-right: 0.3rem;
}

/* ========================= 
   Table Styles 
   ========================= */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background-color: var(--card-dark);
}

body.light table {
  background-color: var(--card-light);
}

th, td {
  border: 1px solid #444;
  padding: 0.5rem;
  text-align: center;
}

th {
  position: relative;
  user-select: none;
  background-color: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 1rem 0.75rem;
}

th .resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  background: rgba(255,255,255,0.08);
}

th .resize-handle:hover {
  background: rgba(255,255,255,0.18);
}

body.light th,
body.light td {
  border-color: #d0d0d0;
}

td {
  vertical-align: middle;
}

table tbody tr:hover {
  background-color: rgba(56, 189, 248, 0.1);
}

body.light table tbody tr:hover {
  background-color: rgba(56, 189, 248, 0.05);
}

/* ========================= 
   Button Variants
   ========================= */
.btn-danger {
  background-color: #ef4444 !important;
  margin: 20px;
}

.btn-danger:hover {
  background-color: #dc2626 !important;
}

.wide {
  grid-column: 1 / -1;
}

/* ========================= 
   Quick Actions Grid
   ========================= */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin: 0.6rem 0;
}

.quick-action-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  background-color: rgba(56, 189, 248, 0.05);
  border-radius: 0.8rem;
  border-left: 3px solid var(--primary);
}

body.light .quick-action-group {
  background-color: rgba(56, 189, 248, 0.02);
}

.quick-action-group h3 {
  margin: 0 0 0.3rem 0;
  font-size: 0.85rem;
  color: var(--primary);
}

.quick-action-group button {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ========================= 
   Timer Input Group
   ========================= */
.timer-input-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 0.8rem 0;
}

.timer-input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timer-input label {
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
  color: var(--text-dark);
}

body.light .timer-input label {
  color: var(--text-light);
}

.timer-input input {
  font-size: 1.2rem;
  text-align: center;
  padding: 0.75rem;
  font-weight: 600;
}

/* ========================= 
   Modal/Dialog Styles
   ========================= */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background-color: var(--card-dark);
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  max-width: 500px;
  width: 90%;
  animation: slideIn 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}

body.light .modal-content {
  background-color: var(--card-light);
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-close {
  float: right;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  color: var(--text-dark);
  background: none;
  border: none;
  padding: 0;
  margin-top: -0.5rem;
  margin-right: -0.5rem;
}

body.light .modal-close {
  color: var(--text-light);
}

.modal-close:hover {
  color: var(--primary);
}

.modal h2 {
  margin-top: 0;
  color: var(--primary);
}

.calendar-header button {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.collapsible-card {
  overflow: hidden;
}

.collapsible-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  color: inherit;
  padding: 0;
  margin: 0 0 0.75rem 0;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: left;
  border-radius: 0;
}

.collapsible-header:hover {
  transform: none;
  box-shadow: none;
  background: transparent;
}

.collapse-indicator {
  transition: transform 0.2s ease;
  font-size: 1rem;
}

.collapsible-card.collapsed .collapse-indicator {
  transform: rotate(-90deg);
}

.collapsible-card.collapsed .collapsible-content {
  display: none;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  align-items: end;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(130px, 1fr) minmax(180px, 1fr) auto;
  gap: 1rem;
  align-items: end;
}

.salary-app #allowanceForm {
  grid-template-columns: minmax(240px, 1.5fr) minmax(180px, 1fr) auto;
  column-gap: 1.75rem;
}

.salary-app #expenseForm {
  grid-template-columns: minmax(240px, 1.5fr) minmax(180px, 1fr) minmax(220px, 1fr) auto;
  column-gap: 1.75rem;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.salary-entry {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-left: 3px solid var(--primary);
  background-color: rgba(56, 189, 248, 0.08);
  border-radius: 0.5rem;
}

.salary-entry strong {
  color: var(--primary);
  white-space: nowrap;
}

.empty-state {
  margin: 0;
  opacity: 0.6;
}

.expense-tag {
  display: inline-block;
  margin-right: 0.55rem;
  padding: 0.15rem 0.45rem;
  border-radius: 0.35rem;
  background-color: rgba(239, 68, 68, 0.18);
  color: #f87171;
  font-size: 0.75rem;
  font-weight: 700;
}

.saving-tag {
  background-color: rgba(34, 197, 94, 0.18);
  color: #4ade80;
}

.summary-box-highlight {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.12);
}

.summary-box-highlight strong {
  color: var(--accent);
}

.salary-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.salary-summary-table {
  margin-top: 0.75rem;
}

.salary-summary-table th:first-child,
.salary-summary-table td:first-child {
  text-align: left;
}

.salary-summary-table td:last-child {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}

.salary-summary-table .salary-summary-total td {
  border-top: 2px solid var(--primary);
  font-weight: 700;
}

.salary-summary-table .salary-summary-highlight td {
  background-color: rgba(16, 185, 129, 0.12);
  color: var(--accent);
  font-weight: 700;
}

.salary-form .form-row:first-child {
  grid-column: 1 / -1;
  max-width: 320px;
  margin-bottom: 0.75rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.summary-box {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 0.8rem;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.summary-box span {
  color: var(--text-dark);
  opacity: 0.8;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

body.light .summary-box span {
  color: var(--text-light);
}

.summary-box strong {
  font-size: 1.2rem;
  color: var(--primary);
}

.delta-positive {
  color: #22c55e;
  font-weight: 700;
}

.delta-negative {
  color: #f87171;
  font-weight: 700;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  text-align: center;
  font-size: 0.8rem;
  color: var(--primary);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
  }

  .salary-app #allowanceForm {
    grid-template-columns: 1fr;
  }

  .salary-app #expenseForm {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .inline-form button {
    width: 100%;
  }

  .salary-entry {
    grid-template-columns: 1fr auto auto;
  }
  
  table {
    font-size: 0.9rem;
  }
  
  th, td {
    padding: 0.4rem;
  }
  
  .button-group {
    flex-direction: column;
  }
  
  .button-group button {
    width: 100%;
  }
  
  .modal-content {
    width: 95%;
    padding: 1rem;
  }
}
