/* ===============================================
   TAWI SYSTEM - GLOBAL CUSTOM CSS
   วิทยาลัยอาชีวศึกษาแพร่
   =============================================== */

/* === GOOGLE FONTS === */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* === CSS VARIABLES === */
:root {
  --primary:        #4361ee;
  --primary-dark:   #3651d4;
  --primary-light:  #eef0fd;
  --secondary:      #6c757d;
  --success:        #2dce89;
  --success-light:  #e8faf3;
  --warning:        #f7c948;
  --warning-light:  #fef9e7;
  --danger:         #f5365c;
  --danger-light:   #fde8ed;
  --info:           #11cdef;
  --info-light:     #e3f9fd;
  --purple:         #7c3aed;
  --purple-light:   #ede9fe;
  --orange:         #fb6340;
  --orange-light:   #fff3f0;

  --bg-soft:        #f4f6fc;
  --bg-white:       #ffffff;
  --text-main:      #344767;
  --text-muted:     #8392ab;
  --border-light:   #e9ecef;
  --shadow-sm:      0 2px 8px rgba(67, 97, 238, 0.08);
  --shadow-md:      0 4px 20px rgba(67, 97, 238, 0.12);
  --shadow-lg:      0 8px 40px rgba(67, 97, 238, 0.16);
  --radius-sm:      0.5rem;
  --radius-md:      0.75rem;
  --radius-lg:      1rem;
  --radius-xl:      1.5rem;
  --transition:     all 0.25s ease;
}

/* === BASE === */
body {
  font-family: 'Sarabun', 'Inter', sans-serif;
  background-color: var(--bg-soft);
  color: var(--text-main);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* === SIDEBAR OVERRIDES === */
.sidebar {
  background: linear-gradient(160deg, #1a1f3a 0%, #2d3561 50%, #1a1f3a 100%) !important;
}

.sidebar-brand {
  background: rgba(255,255,255,0.06) !important;
  border-bottom: 1px solid rgba(255,255,255,0.1) !important;
  padding: 1.25rem 1.5rem !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em;
}

.sidebar-header {
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
  color: rgba(255,255,255,0.35) !important;
  padding: 1rem 1.5rem 0.4rem !important;
}

.sidebar-link {
  color: rgba(255,255,255,0.7) !important;
  border-radius: var(--radius-sm) !important;
  margin: 0.15rem 0.75rem !important;
  padding: 0.6rem 1rem !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  transition: var(--transition) !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem;
}

.sidebar-link:hover {
  color: #fff !important;
  background: rgba(255,255,255,0.1) !important;
  transform: translateX(3px);
}

.sidebar-item.active > .sidebar-link {
  color: #fff !important;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%) !important;
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.4) !important;
}

.sidebar-link i,
.sidebar-link svg {
  width: 18px !important;
  height: 18px !important;
  color: inherit !important;
  flex-shrink: 0;
}

/* === NAVBAR OVERRIDES === */
.navbar-bg {
  background: var(--bg-white) !important;
  border-bottom: 1px solid var(--border-light) !important;
  box-shadow: var(--shadow-sm) !important;
  padding: 0.6rem 1.5rem !important;
}

.navbar .text-dark {
  font-weight: 600 !important;
  color: var(--text-main) !important;
}

/* === MAIN CONTENT === */
.main {
  background: var(--bg-soft);
}

.content {
  padding: 1.5rem !important;
}

/* === CARDS === */
.card {
  border: none !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-sm) !important;
  transition: var(--transition) !important;
  background: var(--bg-white);
}

.card:hover {
  box-shadow: var(--shadow-md) !important;
}

.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border-light) !important;
  padding: 1.1rem 1.5rem !important;
  font-weight: 600 !important;
  color: var(--text-main) !important;
  font-size: 1rem !important;
}

.card-body {
  padding: 1.25rem 1.5rem !important;
}

/* === KPI STAT CARDS === */
.stat-card {
  border-radius: var(--radius-lg) !important;
  border: none !important;
  overflow: hidden;
  position: relative;
}

.stat-card .stat-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-main);
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-card .stat-trend {
  font-size: 0.8rem;
  font-weight: 600;
}

/* === GRADIENT BACKGROUNDS FOR STAT CARDS === */
.bg-gradient-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%) !important;
}
.bg-gradient-success {
  background: linear-gradient(135deg, var(--success) 0%, #17a589 100%) !important;
}
.bg-gradient-warning {
  background: linear-gradient(135deg, var(--warning) 0%, var(--orange) 100%) !important;
}
.bg-gradient-danger {
  background: linear-gradient(135deg, var(--danger) 0%, var(--orange) 100%) !important;
}
.bg-gradient-info {
  background: linear-gradient(135deg, var(--info) 0%, var(--primary) 100%) !important;
}
.bg-gradient-purple {
  background: linear-gradient(135deg, var(--purple) 0%, var(--primary) 100%) !important;
}

.icon-bg-primary   { background: var(--primary-light); color: var(--primary); }
.icon-bg-success   { background: var(--success-light); color: var(--success); }
.icon-bg-warning   { background: var(--warning-light); color: var(--orange); }
.icon-bg-danger    { background: var(--danger-light); color: var(--danger); }
.icon-bg-info      { background: var(--info-light); color: var(--info); }
.icon-bg-purple    { background: var(--purple-light); color: var(--purple); }

/* === TABLES === */
.table {
  --bs-table-hover-bg: rgba(67,97,238,0.04);
  font-size: 0.9rem;
}

.table thead th {
  background: linear-gradient(135deg, var(--primary-light) 0%, #f0f4ff 100%) !important;
  color: var(--primary-dark) !important;
  font-weight: 600 !important;
  font-size: 0.82rem !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  border-bottom: 2px solid rgba(67,97,238,0.15) !important;
  padding: 0.85rem 1rem !important;
  white-space: nowrap;
}

.table td {
  padding: 0.75rem 1rem !important;
  vertical-align: middle !important;
  border-bottom: 1px solid var(--border-light) !important;
  color: var(--text-main);
}

.table tbody tr:last-child td {
  border-bottom: none !important;
}

.table-hover tbody tr:hover {
  background-color: var(--bs-table-hover-bg) !important;
  transition: var(--transition);
}

/* === BUTTONS === */
.btn {
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  font-size: 0.87rem;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  transition: var(--transition);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(67,97,238,0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #2a3fb5 100%);
  box-shadow: 0 6px 20px rgba(67,97,238,0.35);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #1aab74 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(45,206,137,0.25);
}
.btn-success:hover {
  background: linear-gradient(135deg, #22b377 0%, #159660 100%);
  box-shadow: 0 6px 20px rgba(45,206,137,0.35);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #c0052e 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(245,54,92,0.25);
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning) 0%, var(--orange) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(247,201,72,0.25);
}
.btn-warning:hover { color: #fff; transform: translateY(-1px); }

.btn-secondary {
  background: #e9ecef;
  color: var(--secondary);
  box-shadow: none;
}
.btn-secondary:hover {
  background: #dee2e6;
  color: var(--text-main);
}

.btn-outline-primary {
  border: 1.5px solid var(--primary) !important;
  color: var(--primary) !important;
  background: transparent;
}
.btn-outline-primary:hover {
  background: var(--primary-light) !important;
  color: var(--primary-dark) !important;
}

.btn-sm {
  font-size: 0.8rem !important;
  padding: 0.3rem 0.7rem !important;
  border-radius: 0.4rem !important;
}

.btn-lg {
  font-size: 1rem !important;
  padding: 0.75rem 2rem !important;
  border-radius: var(--radius-md) !important;
}

/* === BADGES === */
.badge {
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.4em 0.75em;
  border-radius: 2rem;
}

.badge.bg-primary { background: linear-gradient(135deg, var(--primary), #7c3aed) !important; }
.badge.bg-success { background: linear-gradient(135deg, var(--success), #17a589) !important; }
.badge.bg-warning { background: linear-gradient(135deg, var(--warning), var(--orange)) !important; color:#fff !important; }
.badge.bg-danger  { background: linear-gradient(135deg, var(--danger), var(--orange)) !important; }
.badge.bg-info    { background: linear-gradient(135deg, var(--info), var(--primary)) !important; }
.badge.bg-secondary { background: #8392ab !important; }

/* === PROGRESS BARS === */
.progress {
  border-radius: 2rem;
  background: var(--border-light);
  overflow: visible;
}

.progress-bar {
  border-radius: 2rem;
  font-size: 0.72rem;
  font-weight: 700;
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
  position: relative;
}

.progress-bar.bg-success { background: linear-gradient(90deg, var(--success), #17a589) !important; }
.progress-bar.bg-warning { background: linear-gradient(90deg, var(--warning), var(--orange)) !important; }
.progress-bar.bg-danger  { background: linear-gradient(90deg, var(--danger), var(--orange)) !important; }
.progress-bar.bg-secondary { background: #8392ab !important; }

/* === FORMS === */
.form-control, .form-select {
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: 'Sarabun', sans-serif;
  font-size: 0.9rem;
  color: var(--text-main);
  padding: 0.5rem 0.85rem;
  transition: var(--transition);
  background-color: var(--bg-white);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,0.12);
  outline: none;
}

.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

/* === MODALS === */
.modal-content {
  border: none !important;
  border-radius: var(--radius-xl) !important;
  box-shadow: var(--shadow-lg) !important;
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem 1.5rem !important;
  border-bottom: 1px solid var(--border-light) !important;
}

.modal-header.bg-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%) !important;
}

.modal-header.bg-success {
  background: linear-gradient(135deg, var(--success) 0%, #17a589 100%) !important;
}

.modal-title {
  font-size: 1rem !important;
  font-weight: 700 !important;
}

.modal-body {
  padding: 1.5rem !important;
}

.modal-footer {
  padding: 1rem 1.5rem !important;
  border-top: 1px solid var(--border-light) !important;
  background: #fafbfc;
}

/* === BREADCRUMB === */
.breadcrumb-custom {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.breadcrumb-custom a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.breadcrumb-custom a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.breadcrumb-custom .sep {
  color: #c0c8d8;
  font-size: 0.75rem;
}

.breadcrumb-custom .current {
  color: var(--text-main);
  font-weight: 600;
}

/* === PAGE TITLES === */
.page-title-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title-bar h1, .page-title-bar h2 {
  font-size: 1.4rem !important;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  line-height: 1.3;
}

.page-subtitle {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
}

.empty-state .empty-icon {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: var(--primary);
  margin: 0 auto 1.25rem;
}

.empty-state h5 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.87rem;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto 1.5rem;
}

/* === SECTION DIVIDER === */
.section-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0 1rem;
}

.section-divider span {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* === FOOTER === */
.footer {
  border-top: 1px solid var(--border-light) !important;
  background: var(--bg-white) !important;
  padding: 0.85rem 1.5rem !important;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  font-weight: 500;
}

/* === LOGIN PAGE === */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1f3a 0%, #2d3561 45%, #4361ee 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  top: -200px; right: -100px;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 350px; height: 350px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  bottom: -120px; left: -80px;
}

.login-card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
  width: 90px;
  height: 90px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  box-shadow: 0 8px 30px rgba(67,97,238,0.4);
  overflow: hidden;
}

.login-logo img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 50%;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  text-align: center;
}

.login-subtitle {
  font-size: 0.87rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-input {
  border: 1.5px solid var(--border-light) !important;
  border-radius: var(--radius-md) !important;
  padding: 0.7rem 1rem !important;
  font-size: 0.92rem !important;
  background: #f8f9ff !important;
  transition: var(--transition) !important;
}

.login-input:focus {
  border-color: var(--primary) !important;
  background: var(--bg-white) !important;
  box-shadow: 0 0 0 3px rgba(67,97,238,0.12) !important;
}

.btn-login {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.8rem;
  font-size: 1rem;
  font-weight: 700;
  width: 100%;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 6px 20px rgba(67,97,238,0.35);
  letter-spacing: 0.03em;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(67,97,238,0.45);
}

.btn-login:active {
  transform: translateY(0);
}

/* === ROUND PROGRESS CARDS (main1) === */
.round-card {
  border-radius: var(--radius-lg) !important;
  border: none !important;
  transition: var(--transition);
}

.round-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md) !important;
}

.round-badge {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
}

/* === REPORT PAGE === */
.report-header-card {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border-radius: var(--radius-lg) !important;
  border: none !important;
  color: #fff;
  padding: 1.5rem 2rem;
}

/* === ALERT / TOAST === */
.alert {
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c0c8d8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #8392ab; }

/* === ANIMATIONS === */
.fade-in {
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .content { padding: 1rem !important; }
  .page-title-bar { flex-direction: column; }
  .stat-card .stat-value { font-size: 1.6rem; }
  .login-card { margin: 1rem; padding: 2rem 1.5rem; }
  .table { font-size: 0.82rem; }
  .table thead th { font-size: 0.75rem !important; }
}

/* === MISC UTILITIES === */
.text-orange { color: #fb6340 !important; }
.bg-soft-primary { background: var(--primary-light) !important; }
.bg-soft-success { background: var(--success-light) !important; }
.bg-soft-warning { background: var(--warning-light) !important; }
.bg-soft-danger  { background: var(--danger-light)  !important; }
.rounded-custom  { border-radius: var(--radius-lg) !important; }
.shadow-custom   { box-shadow: var(--shadow-md) !important; }

.hover-lift {
  transition: var(--transition);
  cursor: pointer;
}
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md) !important;
}
