/* GLOBAL ------------------------------ */

body {
  box-sizing: border-box;
}

* {
  box-sizing: border-box;
  font-family: 'K2D', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}


body {
  margin: 0;
  padding: 0;
  font-family: 'K2D', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #6bbcff 0%, #6bbcff 50%, #008cff 100%);
  min-height: 100%;
  overflow-y: auto;
}

.main-wrapper {
  width: 100%;
  min-height: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container {
  width: 100%;
  max-width: 1400px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 30px;
  margin: 0 auto;
}

/* ตัวเลขทั้งหมดใช้ฟอนต์ Inconsolata */
.num,
.payment-amount,
.day-number,
.transaction-total,
select option,
input[type="number"],
.number-font {
    font-family: "Inconsolata", monospace !important;
}

.text,
.label,
.holiday-name,
.day-header,
.modal-title,
.transaction-label {
    font-family: 'K2D', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}
.day-number,
.payment-amount {
  font-family: "Inconsolata", monospace !important;
}
.day-header,
.holiday-name {
  font-family: 'K2D', sans-serif !important;
}

/* FORCE payment amount to black */
.payment-amount {
    color: #000 !important;
}

/* กรณียอด = 0 ให้เป็นสีเทาอ่อน */
.payment-amount.zero {
    color: #a0aec0 !important;
}

/* HEADER ------------------------------ */

.header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between; /* เว้นซ้าย-กลาง-ขวา */
  margin-bottom: 30px;
}

.header-left,
.header-center,
.header-right {
  flex: 1; /* แจกพื้นที่เท่า ๆ กัน */
  display: flex;
  align-items: center;
}

.header-left {
  justify-content: flex-start;
}

.header-center {
  justify-content: center;
}

.header-right {
  justify-content: flex-end; /* ตอนนี้ว่างอยู่ */
}

.company-logo {
  width: 120px;   /* ปรับขนาดโลโก้ */
  height: auto;
  object-fit: contain;
}

.header-center h1 {
  font-size: 2.2em;
  font-weight: 700;
  color: #008cff;
  margin: 0;
}

/* CONTROLS ------------------------------ */

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  gap: 15px;
  flex-wrap: wrap;
}

.nav-buttons {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  background: #008cff;
  color: white;
}

.btn:hover {
  background: #008cff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn:active {
  transform: translateY(0);
}

.month-year-display {
  font-size: 1.8em;
  font-weight: 700;
  color: #333;
}

.selectors {
  display: flex;
  gap: 10px;
}

select {
  padding: 10px 15px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1em;
  cursor: pointer;
  background: white;
  transition: all 0.3s ease;
  font-weight: 600;
}

select:hover {
  border-color:#008cff;
}

select:focus {
  outline: none;
  border-color:#008cff;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* CALENDAR GRID ------------------------------ */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.day-header {
  text-align: center;
  font-weight: 700;
  padding: 15px 5px;
  background: #f7fafc;
  border-radius: 8px;
  font-size: 1em;
  color: #4a5568;
}

.day-header.sunday {
  color: #e53e3e;
}

/* DAY CELL ------------------------------ */

.day-cell {
  min-height: 120px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px;
  background: white;
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.day-cell:hover {
  border-color: #008cff;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
  transform: translateY(-2px);
}

.day-cell.empty {
  background: #f7fafc;
  cursor: default;
  border-color: #edf2f7;
}

.day-cell.empty:hover {
  transform: none;
  box-shadow: none;
}

.day-cell.saturday {
  background: #ebf8ff;
}

.day-cell.sunday,
.day-cell.holiday {
  background: #fff5f5;
}

.day-cell.today {
  border-color: #008cff;
  border-width: 3px;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.day-number {
  font-size: 1.2em;
  font-weight: 700;
  margin-bottom: 5px;
  color: #2d3748;
}

.day-cell.sunday .day-number,
.day-cell.holiday .day-number {
  color: #e53e3e;
}

.holiday-name {
  font-size: 0.75em;
  color: #e53e3e;
  margin-bottom: 8px;
  font-weight: 600;
  line-height: 1.2;
}

.payment-amount {
  margin-top: auto;
  font-size: 1.1em;
  font-weight: 700;
  color: #e53e3e;
  text-align: right;
}

.payment-amount.zero {
  color: #a0aec0;
}

/* MODAL ------------------------------ */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 30px;
  max-width: 600px;
  width: 100%;
  max-height: 80%;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e2e8f0;
}

.modal-title {
  font-size: 1.5em;
  font-weight: 700;
  color: #008cff;
}

.close-btn {
  background: none;
  border: none;
  font-size: 2em;
  cursor: pointer;
  color: #9dc6da;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.close-btn:hover {
  background: #ffffff;
  color: #ff0000;
}

/* TRANSACTION LIST ------------------------------ */

.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.transaction-item {
  padding: 15px;
  background: #f7fafc;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

.transaction-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.transaction-label {
  font-weight: 600;
  color: #4a5568;
}

.transaction-value {
  color: #2d3748;
}

.transaction-total {
  font-size: 1.2em;
  font-weight: 700;
  color: #e53e3e;
}

/* LOADING + ERROR ------------------------------ */

.loading {
  text-align: center;
  padding: 40px;
  font-size: 1.2em;
  color: #008cff;
}

.error-message {
  background: #fff5f5;
  border: 2px solid #fc8181;
  border-radius: 8px;
  padding: 20px;
  margin: 20px 0;
  color: #c53030;
  text-align: center;
}

/* RESPONSIVE ------------------------------ */

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header h1 {
    font-size: 1.8em;
  }

  .controls {
    flex-direction: column;
  }

  .month-year-display {
    font-size: 1.4em;
  }

  .day-cell {
    min-height: 100px;
    padding: 8px;
  }

  .day-number {
    font-size: 1em;
  }

  .payment-amount {
    font-size: 0.9em;
  }

  .holiday-name {
    font-size: 0.7em;
  }

  .selectors {
    width: 100%;
    justify-content: center;
  }

  select {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .day-cell {
    min-height: 90px;
    padding: 6px;
  }

  .day-number {
    font-size: 0.9em;
  }

  .payment-amount {
    font-size: 0.8em;
  }

  .controls {
    gap: 10px;
  }

  .nav-buttons {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .selectors {
    width: 100%;
  }
}

/* ADDITIONAL SMALL SCREEN TUNING ------------------------------ */

@media (max-width: 390px) {
  .header h1 {
    font-size: 1.5em;
  }

  .controls {
    gap: 8px;
  }

  .day-cell {
    min-height: 80px;
  }

  .payment-amount {
    font-size: 0.75em;
  }
}

/* SMOOTH HOVER TRANSITIONS ------------------------------ */

.day-cell,
.btn,
.close-btn,
select {
  transition: all 0.25s ease;
}

/* SCROLLBAR STYLING ------------------------------ */

.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* ANIMATED SHADOW ON HOVER ------------------------------ */

.day-cell:hover {
  box-shadow: 0 6px 18px rgba(102, 126, 234, 0.25);
}

/* OPTIONAL: SMOOTH APPEARING FOR CALENDAR GRID */

.calendar-grid {
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* OPTIONAL: MODAL OVERLAY FADE-IN */

.modal.active {
  animation: fadeInModal 0.25s ease;
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to   { opacity: 1; }
}
