/* =====================================================================
   ระบบจัดเก็บผลงาน ศูนย์การเรียนรู้ สพม.พระนครศรีอยุธยา (award_aya)
   ===================================================================== */

:root {
  --primary: #0d5c46;
  --primary-dark: #073e2f;
  --primary-light: #e6f2ee;
  --accent: #c9a227;
  --text-dark: #1f2a24;
  --text-muted: #667;
  --border: #dfe6e2;
  --bg: #f5f7f6;
  --success: #1b8a5a;
  --warning: #b8860b;
  --danger: #c0392b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', 'Sarabun', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header (public) ---------- */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 16px 0;
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; flex-direction: column; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-title { font-size: 1.15rem; font-weight: 700; }
.brand-sub { font-size: 0.8rem; opacity: 0.85; }
.main-nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.main-nav a { color: #fff; font-size: 0.92rem; }
.nav-user { color: #f0e9d2; font-size: 0.9rem; }
.btn-nav {
  background: var(--accent);
  color: #1f2a24 !important;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 600;
}
.btn-nav:hover { text-decoration: none; opacity: 0.9; }

.main-content { padding: 30px 20px 60px; }

/* ---------- Hero / Search ---------- */
.hero { text-align: center; margin-bottom: 24px; }
.hero h1 { font-size: 1.8rem; color: var(--primary-dark); margin-bottom: 6px; }
.hero p { color: var(--text-muted); max-width: 640px; margin: 0 auto; }
.hero-sm { margin-bottom: 18px; }
.hero-sm h1 { font-size: 1.4rem; }

.search-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 26px;
}
.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.search-form input[type=text],
.search-form select {
  flex: 1 1 180px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
}

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 6px;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: #eef1f0; color: var(--text-dark); }
.btn-secondary:hover { background: #e2e7e5; text-decoration: none; }
.btn-block { width: 100%; }

/* ---------- Works grid ---------- */
.result-count { color: var(--text-muted); margin-bottom: 14px; font-size: 0.9rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}
.work-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: block;
  color: var(--text-dark);
  transition: transform .15s ease, box-shadow .15s ease;
}
.work-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(13,92,70,0.12); text-decoration: none; }
.work-cover { aspect-ratio: 4/3; background: var(--primary-light); overflow: hidden; }
.work-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.work-cover-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); opacity: 0.5; font-size: 0.85rem;
}
.work-cover-placeholder.large { min-height: 260px; }
.work-info { padding: 12px 14px; }
.work-info h3 { font-size: 1rem; margin: 0 0 6px; color: var(--primary-dark); }
.work-meta { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 4px; }
.work-meta-sub { font-size: 0.78rem; color: #98a29c; margin: 0; }

.empty-state {
  text-align: center;
  padding: 40px 10px;
  color: var(--text-muted);
}

.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 26px; }
.pagination a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dark);
}
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination a:hover { text-decoration: none; background: var(--primary-light); }

/* ---------- Work detail ---------- */
.back-link { display: inline-block; margin-bottom: 16px; font-size: 0.9rem; }
.work-detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 28px; }
.work-detail-cover img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.work-detail-info h1 { font-size: 1.5rem; color: var(--primary-dark); margin-top: 0; }
.work-description { margin-top: 18px; }
.work-files { margin-top: 20px; }
.work-files ul { padding-left: 20px; }
@media (max-width: 760px) {
  .work-detail-grid { grid-template-columns: 1fr; }
}

/* ---------- School logo / code ---------- */
.school-logo-thumb {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
  vertical-align: middle;
}
.school-logo-thumb-lg { width: 80px; height: 80px; }
.school-logo-inline { width: 18px; height: 18px; margin: 0 2px -4px 0; }
.work-school-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.92rem;
  color: var(--text-dark);
}
.work-school-badge small { color: var(--text-muted); font-weight: 400; }
.work-school-badge { text-decoration: none; }
.work-school-badge:hover { text-decoration: none; opacity: 0.85; }

/* ---------- Homepage: school cards ---------- */
.stat-cards-public {
  display: grid;
  grid-template-columns: repeat(3, 1fr) 1.4fr;
  gap: 14px;
  margin-bottom: 30px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .stat-cards-public { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .stat-cards-public { grid-template-columns: 1fr; }
}
.stat-search-form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}
.stat-search-form input[type=text] {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.schools-section { margin-top: 10px; }

.school-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
}
.school-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  color: var(--text-dark);
  transition: transform .15s ease, box-shadow .15s ease;
}
.school-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(13,92,70,0.12); text-decoration: none; }
.school-card-logo {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}
.school-card-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.school-card-logo-placeholder { font-size: 1.4rem; color: var(--primary); opacity: 0.5; }
.school-card-name { font-size: 0.95rem; margin: 0; color: var(--primary-dark); line-height: 1.3; }

/* ---------- School detail page ---------- */
.school-detail-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 26px;
}
.school-detail-logo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.school-detail-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.school-detail-header h1 { font-size: 1.4rem; color: var(--primary-dark); margin: 0 0 6px; }

.attachment-list { list-style: none; padding: 0; margin: 0; }
.attachment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}
.attachment-item:last-child { border-bottom: none; }
.attachment-info { min-width: 0; }
.attachment-title {
  display: block;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 4px;
}
.attachment-title:hover { text-decoration: underline; }

/* ---------- Auth ---------- */
.auth-box {
  max-width: 380px;
  margin: 20px auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.auth-box h1 { font-size: 1.3rem; color: var(--primary-dark); margin-bottom: 4px; }
.auth-sub { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-form label { font-size: 0.85rem; margin-top: 10px; font-weight: 600; }
.auth-form input {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; margin-top: 4px;
}
.auth-form button { margin-top: 18px; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6cb; }
.alert-success { background: #eaf6ef; color: var(--success); border: 1px solid #c3e6cb; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--primary-dark);
  color: #d9e6e0;
  text-align: center;
  padding: 16px 0;
  font-size: 0.82rem;
  margin-top: 40px;
}

/* ---------- Dashboard layout (admin / staff) ---------- */
.dashboard-body { background: var(--bg); }
.dashboard-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--primary-dark);
  color: #fff;
  flex-shrink: 0;
  padding: 20px 0;
}
.sidebar-brand { padding: 0 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.15); margin-bottom: 12px; }
.sidebar-brand strong { display: block; font-size: 1rem; }
.sidebar-brand span { font-size: 0.78rem; opacity: 0.8; }
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-nav a {
  color: #d9e6e0;
  padding: 11px 20px;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
  border-left-color: var(--accent);
}
.dashboard-content { flex: 1; min-width: 0; }
.dashboard-topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 16px 26px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dashboard-topbar h2 { margin: 0; font-size: 1.15rem; color: var(--primary-dark); }
.topbar-user { font-size: 0.88rem; color: var(--text-muted); }
.dashboard-main { padding: 22px 26px 50px; }

@media (max-width: 860px) {
  .dashboard-layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
}

/* ---------- Stat cards ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card.stat-warning { border-left-color: var(--warning); }
.stat-card.stat-success { border-left-color: var(--success); }
.stat-card.stat-danger { border-left-color: var(--danger); }
.stat-number { display: block; font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); }
.stat-label { font-size: 0.82rem; color: var(--text-muted); }

/* ---------- Panels & tables ---------- */
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 22px;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-header h3 { margin: 0; font-size: 1.05rem; color: var(--primary-dark); }

.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tabs a {
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.85rem;
}
.filter-tabs a.active { background: var(--primary); color: #fff; }
.filter-tabs a:hover { text-decoration: none; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.data-table th { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.data-table tr:hover td { background: #fafcfb; }

.actions-cell { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.link-btn {
  background: none; border: none; padding: 0; color: var(--primary);
  font-size: 0.88rem; cursor: pointer; text-decoration: underline;
}
.link-btn.link-danger { color: var(--danger); }
.link-btn.link-warning { color: var(--warning); }
.link-btn.link-success { color: var(--success); }
.link-btn:disabled { color: #bbb; cursor: not-allowed; text-decoration: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-pending { background: #fdf3e0; color: var(--warning); }
.badge-approved { background: #e4f5eb; color: var(--success); }
.badge-rejected { background: #fbe6e3; color: var(--danger); }

/* ---------- Forms ---------- */
.stacked-form, .inline-form { display: flex; flex-direction: column; gap: 12px; }
.inline-form { flex-direction: row; flex-wrap: wrap; align-items: center; }
.inline-form input[type=text] {
  flex: 1 1 200px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
}
.stacked-form label { font-size: 0.85rem; font-weight: 600; margin-bottom: -6px; }
.stacked-form input[type=text],
.stacked-form input[type=email],
.stacked-form input[type=password],
.stacked-form input[type=file],
.stacked-form select,
.stacked-form textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.92rem; width: 100%;
  font-family: inherit;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-row > div { display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 0.85rem; font-weight: 600; }
.form-hint { color: var(--text-muted); font-size: 0.85rem; margin: 4px 0; }
.current-file { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 6px; }

hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
