/* css/style.css - Notifikasi Kemaskini iDMe */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --primary-blue: #0284c7;
  --primary-blue-dark: #0369a1;
  --primary-orange: #ea580c;
  --primary-orange-dark: #c2410c;
  --danger-red: #ef4444;
  --danger-red-bg: #f87171;
  --danger-red-dark: #dc2626;
  --success-green: #10b981;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #000000;
  --border-light: #cbd5e1;
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  
  /* Weekly pastel colors for table body cells (Solid Opaque) */
  --week-color-1: #dcfce7; /* Greenish */
  --week-color-2: #fef9c3; /* Yellowish */
  --week-color-3: #ffe4e6; /* Pink/Rose */
  --week-color-4: #dbeafe; /* Sky Blue */
  --week-color-5: #f3e8ff; /* Purple/Lavender */
  --week-color-6: #ffedd5; /* Warm Orange/Peach */
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================================
   MAIN HEADER (DIGELAPKAN)
   ======================================================== */
.top-navbar {
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 60;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.brand-titles h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--primary-blue);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-blue-dark);
  box-shadow: 0 4px 6px -1px rgba(2, 132, 199, 0.4);
}

.btn-send-all {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  padding: 9px 18px;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.35);
}

.btn-send-all:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  transform: translateY(-1px);
}

.btn-outline {
  background-color: #1e293b;
  color: #f1f5f9;
  border: 1px solid #334155;
}

.btn-outline:hover {
  background-color: #334155;
  border-color: #475569;
}

.btn-idme {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border: 1px solid #10b981;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3);
}

.btn-idme:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.825rem;
  font-weight: 700;
}

/* Main Container */
.main-wrapper {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px;
  flex: 1;
}

/* ========================================================
   HEADER FILTER / CONTROL BAR (DIGELAPKAN)
   ======================================================== */
.control-bar {
  background: #1e293b;
  border-radius: 12px;
  padding: 12px 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
  border: 1px solid #334155;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.control-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.picker-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.picker-group label {
  font-size: 0.85rem;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none !important;
  padding: 7px 16px;
  border-radius: 8px;
  border: 1.5px solid #475569;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
  background-color: #0f172a;
  outline: none;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.form-select::-ms-expand {
  display: none;
}

.form-select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.form-select option {
  background-color: #0f172a;
  color: #ffffff;
}

/* Session Filter Pills */
.session-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-group label {
  font-size: 0.85rem;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.session-pills {
  display: flex;
  background: #0f172a;
  border: 1px solid #334155;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}

.session-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 700;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
}

.session-btn:hover {
  color: #ffffff;
}

.session-btn.active {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.4);
}

/* Control Right */
.control-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ========================================================
   TABLE SECTION - SOLID BORDERS & OPAQUE STICKY HEADERS
   ======================================================== */
.table-card {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border: 2px solid #000000;
  overflow: hidden;
  margin-bottom: 20px;
}

.table-responsive-container {
  overflow-x: auto;
  max-height: 80vh;
  position: relative;
  background: #ffffff;
}

.idme-matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-top: 1.5px solid #000000;
  border-left: 1.5px solid #000000;
  font-size: 0.95rem;
  text-align: center;
  background: #ffffff;
}

.idme-matrix-table th, 
.idme-matrix-table td {
  border-right: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  padding: 0;
  height: 32px;
  vertical-align: middle;
  background-clip: padding-box;
}

/* Sticky Class Column (Left) */
.col-sticky-kelas {
  position: sticky;
  left: 0;
  z-index: 25;
  width: 170px;
  min-width: 170px;
  max-width: 170px;
  text-align: center;
  font-weight: 800;
  background-color: #ffffff;
  box-shadow: 2px 0 0 #000000;
}

/* Sticky Action Column (Right) */
.col-sticky-action {
  position: sticky;
  right: 0;
  z-index: 25;
  width: 140px;
  min-width: 140px;
  background-color: #ffffff;
  box-shadow: -2px 0 0 #000000;
  padding: 3px 6px !important;
}

/* Header Rows Sticky Positioning (100% Opaque z-index 40 & 55) */
.idme-matrix-table thead {
  position: sticky;
  top: 0;
  z-index: 40;
}

.idme-matrix-table thead tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 32px;
}

.idme-matrix-table thead tr:nth-child(2) th {
  position: sticky;
  top: 32px;
  z-index: 40;
  height: 32px;
}

/* Header Sticky Corners (Cross-axis sticky) */
.idme-matrix-table thead th.col-sticky-kelas {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 55 !important;
  background-color: var(--primary-orange) !important;
  color: #ffffff !important;
}

.idme-matrix-table thead th.col-sticky-action {
  position: sticky;
  right: 0;
  top: 0;
  z-index: 55 !important;
  background-color: var(--primary-orange) !important;
  color: #ffffff !important;
}

/* Header Bold Column Labels */
.th-kelas-header {
  background-color: var(--primary-orange) !important;
  color: #ffffff !important;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.th-action-header {
  background-color: var(--primary-orange) !important;
  color: #ffffff !important;
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.th-day-name {
  font-size: 0.85rem;
  font-weight: 900;
}

.th-date-number {
  font-size: 0.85rem;
  font-weight: 900;
  cursor: pointer;
}

.th-date-number:hover {
  filter: brightness(0.85);
}

/* Date cell width */
.col-date {
  width: 32px;
  min-width: 32px;
  max-width: 32px;
}

/* ========================================================
   WARNA HEADER DIGELAPKAN SEDIKIT MENGIKUT JALUR MINGGU
   ======================================================== */
th.th-day-name.week-band-1, th.th-date-number.week-band-1 { 
  background-color: #86efac !important; 
  color: #064e3b !important; 
}
th.th-day-name.week-band-2, th.th-date-number.week-band-2 { 
  background-color: #fde047 !important; 
  color: #713f12 !important; 
}
th.th-day-name.week-band-3, th.th-date-number.week-band-3 { 
  background-color: #fda4af !important; 
  color: #881337 !important; 
}
th.th-day-name.week-band-4, th.th-date-number.week-band-4 { 
  background-color: #93c5fd !important; 
  color: #1e3a8a !important; 
}
th.th-day-name.week-band-5, th.th-date-number.week-band-5 { 
  background-color: #d8b4fe !important; 
  color: #581c87 !important; 
}
th.th-day-name.week-band-6, th.th-date-number.week-band-6 { 
  background-color: #fdba74 !important; 
  color: #7c2d12 !important; 
}

/* Warna Kotak Semak (Body) Mengikut Jalur Minggu (Pastel Lembut) */
td.week-band-1 { background-color: var(--week-color-1) !important; }
td.week-band-2 { background-color: var(--week-color-2) !important; }
td.week-band-3 { background-color: var(--week-color-3) !important; }
td.week-band-4 { background-color: var(--week-color-4) !important; }
td.week-band-5 { background-color: var(--week-color-5) !important; }
td.week-band-6 { background-color: var(--week-color-6) !important; }

/* Table Body Row Styling */
.table-row-kelas td {
  background-color: #ffffff;
}

.table-row-kelas:hover td:not(.col-date):not(.kelas-cell-unupdated) {
  background-color: #f1f5f9;
}

/* Penonjolan Merah Bagi Kelas Belum Dikemaskini */
.kelas-cell-unupdated {
  background-color: var(--danger-red-bg) !important;
  color: #000000 !important;
  font-weight: 900 !important;
}

.kelas-name-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 800;
}

.kelas-name-desktop {
  display: inline;
}

.kelas-name-mobile {
  display: none;
}

.badge-hari-count {
  background: #dc2626;
  color: #ffffff;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 9999px;
  font-weight: 800;
}

/* Checkbox Cell */
.cell-checkbox-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Custom Checkbox matching the screenshot */
.cell-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid #000000;
  border-radius: 2px;
  background-color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease;
  margin: 0;
}

.cell-checkbox:hover {
  transform: scale(1.15);
}

.cell-checkbox:checked {
  background-color: #000000;
}

.cell-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

/* Action Cell Buttons */
.action-cell-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-send-single {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.btn-send-single.has-overdue {
  background: #dc2626;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.4);
}

.btn-send-single.has-overdue:hover {
  background: #b91c1c;
}

.btn-preview-single {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-preview-single:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* BUTTON TIDAK AKTIF (DISABLED) BILA TIADA TARIKH DITANDA */
.btn-send-single:disabled,
.btn-send-single.disabled,
.btn-preview-single:disabled,
.btn-preview-single.disabled {
  opacity: 0.3 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  background: #94a3b8 !important;
  color: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: none !important;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-box {
  transform: scale(1);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #1e293b;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 0.95rem;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Telegram Preview Box */
.telegram-preview-box {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 16px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  color: #1e1b4b;
  line-height: 1.5;
  user-select: all;
  margin: 12px 0;
  max-height: 350px;
  overflow-y: auto;
}

/* Progress Container */
.progress-container {
  margin: 16px 0;
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.info { background: #2563eb; }

/* Tanda Right Hijau Di Sebelah Kiri Button Hantar */
.badge-sent-tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #16a34a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  flex-shrink: 0;
  display: none;
  margin-right: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.badge-sent-tick.visible {
  display: inline-flex;
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spin {
  animation: spin 0.8s linear infinite;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========================================================
   RESPONSIF MESRA TELEFON PINTAR (MOBILE FRIENDLY)
   ======================================================== */
@media (max-width: 768px) {
  /* Sembunyikan label teks untuk Kemaskini, Hantar Notifikasi & Kosongkan (Hanya paparkan icon sahaja) */
  .top-actions .btn .btn-label,
  #btn-reset-month .btn-label {
    display: none !important;
  }

  .top-actions .btn,
  #btn-reset-month {
    padding: 7px 10px !important;
    min-width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0 !important;
    border-radius: 8px;
  }

  .top-navbar {
    padding: 8px 12px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .top-navbar .brand-section {
    width: auto;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .brand-logo {
    width: 26px;
    height: 26px;
  }

  .brand-titles h1 {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0;
    white-space: nowrap;
  }

  .top-actions {
    width: auto;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .main-wrapper {
    padding: 8px 6px;
  }

  .control-bar {
    padding: 8px 10px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .control-left {
    width: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .control-right {
    width: auto;
    display: flex;
    align-items: center;
  }

  /* Sembunyikan label Bulan: dan Sesi: dalam mod telefon */
  .picker-group label,
  .session-group label {
    display: none !important;
  }

  .form-select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: none !important;
    padding: 5px 12px;
    font-size: 0.8rem;
    text-align: center;
  }

  .session-btn {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  /* Table styling for mobile touch devices */
  .table-responsive-container {
    -webkit-overflow-scrolling: touch;
    max-height: 75vh;
  }

  .kelas-name-desktop {
    display: none !important;
  }

  .kelas-name-mobile {
    display: inline !important;
    white-space: nowrap !important;
    font-size: 0.72rem !important;
  }

  .col-sticky-kelas {
    width: 105px !important;
    min-width: 105px !important;
    max-width: 105px !important;
    padding: 2px 3px !important;
    box-sizing: border-box !important;
  }

  .th-kelas-header {
    font-size: 0.82rem !important;
    letter-spacing: 0.5px !important;
  }

  .kelas-name-label {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    font-size: 0.72rem !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  .badge-hari-count {
    font-size: 0.65rem !important;
    padding: 1px 5px !important;
    flex-shrink: 0 !important;
  }

  .col-date {
    width: 30px;
    min-width: 30px;
    max-width: 30px;
    font-size: 0.8rem;
  }

  .cell-checkbox {
    width: 19px;
    height: 19px;
  }

  /* Lajur Tindakan & Butang Hantar dalam jadual: Muat Kemas & Tidak Terkeluar */
  .col-sticky-action {
    width: 76px !important;
    min-width: 76px !important;
    max-width: 76px !important;
    padding: 2px 3px !important;
    box-sizing: border-box !important;
  }

  .action-cell-btns {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    width: 100% !important;
  }

  .th-action-header {
    font-size: 0.68rem !important;
    letter-spacing: 0 !important;
    padding: 2px !important;
    white-space: nowrap !important;
  }

  .btn-send-single span,
  .btn-send-single .btn-send-label {
    display: none !important;
  }

  .btn-send-single {
    padding: 4px !important;
    min-width: 25px !important;
    width: 25px !important;
    height: 25px !important;
    gap: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }

  .btn-preview-single {
    padding: 4px !important;
    min-width: 24px !important;
    width: 24px !important;
    height: 25px !important;
    font-size: 0.7rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }

  .badge-sent-tick {
    width: 15px !important;
    height: 15px !important;
    font-size: 9px !important;
    margin-right: 1px !important;
    flex-shrink: 0 !important;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
}
