/* ITD - Information Technology and Digital Office */
/* Thai Font */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #0d1b2a;
  --sidebar-hover: #1a3a5c;
  --sidebar-active: #1e88e5;
  --primary: #1e88e5;
  --primary-dark: #1565c0;
  --secondary: #00bcd4;
  --success: #43a047;
  --warning: #fb8c00;
  --danger: #e53935;
  --body-bg: #f0f4f8;
  --card-shadow: 0 2px 12px rgba(0,0,0,.08);
  --transition: all .2s ease;
}

* { box-sizing: border-box; }

body {
  font-family: 'Sarabun', sans-serif;
  background: var(--body-bg);
  color: #212529;
  font-size: 15px;
  margin: 0;
}

/* ===== LAYOUT ===== */
.app-wrapper { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1050;   /* > overlay (1040) — sidebar always on top */
  transition: var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  text-decoration: none;
}

.sidebar-brand .brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
  margin-bottom: 8px;
}

.sidebar-brand .brand-title {
  font-size: 18px; font-weight: 700;
  color: #fff; line-height: 1.2;
  display: block;
}

.sidebar-brand .brand-subtitle {
  font-size: 11px; color: rgba(255,255,255,.5);
  display: block; margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.3);
  padding: 12px 20px 4px;
  text-transform: uppercase;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  border-radius: 0;
  transition: var(--transition);
  font-size: 14px;
  gap: 12px;
}

.sidebar-link i { font-size: 17px; width: 20px; text-align: center; }
.sidebar-link .link-text { flex: 1; }
.sidebar-link .badge-count {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  padding-left: 24px;
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar-link.active i { color: #fff; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: rgba(255,255,255,.8);
}

.sidebar-user .user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}

.sidebar-user .user-name { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-user .user-role { font-size: 11px; color: rgba(255,255,255,.5); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topbar .page-title {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a2e;
  margin: 0;
}

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

.content-area { padding: 24px 28px; flex: 1; }

/* ===== CARDS ===== */
.card {
  border: none;
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  background: #fff;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #f0f0f0;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 15px;
}

/* ===== STAT CARDS ===== */
.stat-card {
  border-radius: 14px;
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  transition: transform .2s;
}

.stat-card:hover { transform: translateY(-3px); }

.stat-card .stat-icon {
  position: absolute;
  right: 16px; top: 16px;
  font-size: 48px;
  opacity: .15;
}

.stat-card .stat-value {
  font-size: 32px; font-weight: 700;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 13px; opacity: .85;
  margin-top: 4px;
}

.stat-card .stat-pct {
  font-size: 12px; opacity: .7;
  margin-top: 2px;
}

.stat-total { background: linear-gradient(135deg, #1e88e5, #42a5f5); }
.stat-internal { background: linear-gradient(135deg, #43a047, #66bb6a); }
.stat-share { background: linear-gradient(135deg, #fb8c00, #ffa726); }
.stat-budget { background: linear-gradient(135deg, #8e24aa, #ab47bc); }

/* ===== QUARTER CARDS ===== */
.quarter-card {
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--card-shadow);
  padding: 16px;
  text-align: center;
  border-left: 4px solid var(--primary);
  transition: transform .2s;
}

.quarter-card:hover { transform: translateY(-2px); }
.quarter-card.active-quarter { border-color: var(--warning); background: #fffbf0; }
.quarter-card .q-number { font-size: 24px; font-weight: 700; color: var(--primary); }
.quarter-card .q-label { font-size: 12px; color: #666; }
.quarter-card .q-count { font-size: 22px; font-weight: 700; margin-top: 4px; }

/* ===== TABLES ===== */
.table-modern { border-collapse: separate; border-spacing: 0; }
.table-modern th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 13px;
  color: #495057;
  border-bottom: 2px solid #dee2e6;
  padding: 12px 14px;
  white-space: nowrap;
}

.table-modern td {
  padding: 12px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}

.table-modern tbody tr:hover { background: #f8fbff; }
.table-modern tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  gap: 5px;
}

.status-badge::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ===== BUTTONS ===== */
.btn { font-family: 'Sarabun', sans-serif; border-radius: 8px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 16px;
}

/* ===== FORMS ===== */
.form-control, .form-select {
  border-radius: 8px;
  border: 1.5px solid #dee2e6;
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,136,229,.15);
}

.form-label { font-weight: 500; font-size: 14px; color: #374151; margin-bottom: 5px; }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0d1b2a 0%, #1a3a5c 50%, #0d1b2a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff;
  margin: 0 auto 20px;
}

.login-title { font-size: 22px; font-weight: 700; color: #1a1a2e; text-align: center; }
.login-subtitle { font-size: 13px; color: #666; text-align: center; margin-bottom: 28px; }

/* OTP boxes */
.otp-input {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 6px;
  text-align: center;
}

/* ===== ALERTS ===== */
.alert { border-radius: 10px; border: none; font-size: 14px; }
.alert-success { background: #e8f5e9; color: #2e7d32; }
.alert-danger { background: #ffebee; color: #c62828; }
.alert-warning { background: #fff8e1; color: #f57f17; }
.alert-info { background: #e3f2fd; color: #1565c0; }

/* ===== PROGRESS BAR ===== */
.wg-progress-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
}
.wg-progress-row:last-child { border-bottom: none; }
.wg-progress-label { width: 140px; font-size: 13px; font-weight: 500; flex-shrink: 0; }
.wg-progress-bar-wrap { flex: 1; }
.wg-progress-bar {
  height: 22px;
  border-radius: 4px;
  transition: width .6s ease;
  min-width: 4px;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 8px;
  font-size: 12px; color: #fff; font-weight: 500;
}
.wg-progress-count { width: 50px; text-align: right; font-size: 13px; font-weight: 600; }

/* ===== CHART CONTAINERS ===== */
.chart-container { position: relative; }

/* ===== BREADCRUMB ===== */
.breadcrumb { font-size: 13px; }
.breadcrumb-item + .breadcrumb-item::before { content: '›'; }

/* ===== MODALS ===== */
.modal-content { border-radius: 14px; border: none; }
.modal-header { border-bottom: 1px solid #f0f0f0; }
.modal-footer { border-top: 1px solid #f0f0f0; }

/* ===== ATTACHMENT ITEM ===== */
.attachment-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1.5px solid #e9ecef;
  border-radius: 10px;
  background: #fafbfc;
  transition: var(--transition);
}
.attachment-item:hover { border-color: var(--primary); background: #f0f8ff; }
.attachment-item .att-icon { font-size: 24px; flex-shrink: 0; }
.attachment-item .att-name { flex: 1; font-size: 14px; font-weight: 500; }
.attachment-item .att-size { font-size: 12px; color: #888; }

/* ===== SIDEBAR TOGGLE (mobile) ===== */
.sidebar-toggle-btn {
  display: none;
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  padding: 4px;
}

/* ===== UTILITY ===== */
.text-muted { color: #868e96 !important; }
.fw-600 { font-weight: 600; }
.rounded-lg { border-radius: 12px; }
.cursor-pointer { cursor: pointer; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: #aaa;
}
.empty-state i { font-size: 56px; margin-bottom: 12px; }
.empty-state p { font-size: 16px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
  .sidebar-toggle-btn { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .3s ease;
  }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .content-area { padding: 16px; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fadeInUp .4s ease; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); }
