/* ========== VARIABLES ========== */
:root {
  /* Dynamic rich colors - Aligned with SMK Tinggi (Green & Yellow) */
  --primary-hue: 135;
  /* Forest Green */
  --secondary-hue: 48;
  /* School Yellow/Gold */

  --primary: hsl(var(--primary-hue), 90%, 60%);
  --primary-hover: hsl(var(--primary-hue), 90%, 50%);
  --primary-light: hsl(var(--primary-hue), 90%, 90%);
  /* For faint backgrounds */

  --secondary: hsl(var(--secondary-hue), 80%, 45%);

  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;

  /* Glassmorphism Surface Colors */
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  --glass-blur: 20px;

  /* Form Elements */
  --input-bg: rgba(255, 255, 255, 0.7);
  --input-border: rgba(156, 163, 175, 0.4);

  --radius: 20px;
  --radius-sm: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

/* ========== BASE & BOOT ========== */
body.loading-state {
  overflow: hidden;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: #f8fafc;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease-out, visibility 0.5s;
}

.loading-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.loader-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  animation: pulse 2s infinite ease-in-out;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(22, 163, 74, 0.1);
  border-left-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.05);
    opacity: 1;
  }
}

/* ========== RESET & BASE ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  /* Mesh Gradient Background */
  background-color: #f3f4f6;
  background-image:
    radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
    radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
  background-image:
    radial-gradient(at 40% 20%, hsla(var(--primary-hue), 100%, 92%, 1) 0px, transparent 50%),
    radial-gradient(at 80% 0%, hsla(var(--secondary-hue), 100%, 94%, 1) 0px, transparent 50%),
    radial-gradient(at 0% 50%, hsla(var(--primary-hue), 100%, 95%, 1) 0px, transparent 50%),
    radial-gradient(at 80% 50%, hsla(var(--secondary-hue), 100%, 92%, 1) 0px, transparent 50%),
    radial-gradient(at 0% 100%, hsla(var(--primary-hue), 100%, 92%, 1) 0px, transparent 50%),
    radial-gradient(at 80% 100%, hsla(var(--secondary-hue), 100%, 94%, 1) 0px, transparent 50%),
    radial-gradient(at 0% 0%, hsla(var(--primary-hue), 100%, 95%, 1) 0px, transparent 50%);
  background-attachment: fixed;
  background-size: 150% 150%;
  animation: bgPulse 20s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.hidden {
  display: none !important;
}

/* ========== UTILITIES FOR GLASS ========== */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius);
}

/* ========== LAYOUT & SCREENS ========== */
.screen {
  min-height: 100vh;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Center Content (Auth) */
#auth-screen {
  justify-content: center;
  align-items: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.lang-switcher,
.auth-lang-switcher {
  display: flex;
  background: rgba(255, 255, 255, 0.4);
  padding: 4px;
  border-radius: 99px;
  border: 1px solid var(--glass-border);
}

.lang-btn {
  background: transparent;
  border: none;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 99px;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.lang-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.auth-lang-switcher {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 10;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  padding-right: 45px !important;
  width: 100%;
}

.password-toggle {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  font-size: 1rem;
  transition: color 0.2s ease;
}

.password-toggle:hover {
  color: var(--primary);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  margin: 2rem;
  padding-top: 1rem;
  position: relative;
  perspective: 1000px;
}

.auth-box-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--text-main);
  text-align: center;
  position: relative;
}

.auth-box-title::after {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: var(--primary);
  margin: 0.5rem auto 0;
  border-radius: 2px;
}

.auth-box {
  background: var(--glass-bg);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 3rem 2rem 2rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s var(--transition);
}

.auth-school-branding {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.auth-school-logo {
  width: 100px;
  height: 100px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.1));
}

.auth-school-name {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  color: hsl(var(--primary-hue), 50%, 30%);
  letter-spacing: 0.05em;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* ========== FORM ELEMENTS ========== */
.field,
.form-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  margin-left: 4px;
}

input,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--input-bg);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

input:focus,
textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
  /* Primary color low opacity */
}

/* Auth Buttons */
.btn {
  width: 100%;
  padding: 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, hsl(var(--secondary-hue), 90%, 60%) 100%);
  color: #fff;
  box-shadow: 0 4px 14px 0 rgba(135, 100, 30, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(135, 100, 30, 0.3);
  filter: brightness(110%);
}

/* Match Buka Profil to Primary */
.btn-open-profile {
  display: block;
  /* Force full width in share box */
  width: 100%;
  /* Align with close button */
  text-align: center;
  text-decoration: none;
  margin-bottom: 0.75rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 700;

  background: linear-gradient(135deg, var(--primary) 0%, hsl(var(--secondary-hue), 90%, 60%) 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px 0 rgba(135, 100, 30, 0.2);
  transition: var(--transition);
}

.btn-open-profile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(135, 100, 30, 0.3);
  filter: brightness(115%);
}

.btn-open-profile::after {
  content: ' ↗';
  font-size: 0.9em;
  opacity: 0.8;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  width: auto;
  display: inline-block;
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
}

.btn-outline:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

/* Hints & Messages */
.auth-hint code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8em;
}

.auth-message {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  min-height: 20px;
}

.auth-message.error {
  color: #dc2626;
}

.auth-message.success {
  color: #16a34a;
}

.auth-switch,
.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.link-btn,
.btn-link {
  background: none;
  border: none;
  font: inherit;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}

.link-btn:hover {
  text-decoration: underline;
}


/* ========== EDIT/MAIN SCREEN ========== */
/* Header */
#edit-screen .header,
#public-screen .header {
  margin-bottom: 2rem;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(15px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.school-branding {
  display: flex;
  align-items: center;
  gap: 12px;
}

.school-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.school-info {
  display: flex;
  flex-direction: column;
}

.school-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: -4px;
}

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  background: linear-gradient(to right, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav {
  display: flex;
  background: rgba(0, 0, 0, 0.04);
  padding: 4px;
  border-radius: 99px;
  gap: 4px;
}

.nav-link {
  text-decoration: none;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 6px 16px;
  border-radius: 99px;
  font-weight: 600;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--text-main);
}

.nav-link.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* User Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.current-user {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.5);
  padding: 4px 12px;
  border-radius: 99px;
}

/* Main Content Area */
.main {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
}

/* Section Headings */
.section {
  margin-bottom: 3rem;
  scroll-margin-top: 5rem;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title::before {
  content: '';
  display: block;
  width: 8px;
  height: 28px;
  background: var(--primary);
  border-radius: 4px;
}

.sub-title {
  font-size: 1.2rem;
  color: var(--primary);
  margin-bottom: 0.8rem;
  font-weight: 600;
}

/* Cards inside Sections */
.card {
  /* Using glass panel styles */
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius);

  padding: 2rem;
  margin-bottom: 1.5rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

/* Digital Channels Grid */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.link-item {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 1rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.link-item:focus-within,
.link-item:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--primary);
  transform: scale(1.02);
}

.link-icon {
  font-size: 1.5rem;
  display: block;
  margin-bottom: 0.5rem;
}

.link-label {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  display: block;
}

.link-input {
  font-size: 0.8rem;
  padding: 0.6rem;
  background: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.75rem;
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.link-btn-open {
  width: 100%;
  padding: 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: block;
  text-align: center;
}

.link-btn-open:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

/* Footer */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
}

/* ========== PUBLIC PROFILE ========== */
.public-intro {
  text-align: center;
}

.public-name {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.public-meta {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.5rem;
}

/* Description List for Data */
.dl-list {
  display: grid;
  gap: 1rem;
}

.dl-list dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.dl-list dd {
  font-size: 1.1rem;
  color: var(--text-main);
  font-weight: 500;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
  padding-bottom: 0.5rem;
}

.dl-list dd:last-child {
  border-bottom: none;
}

/* Public Links */
.public-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
}

.public-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: #fff;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
}

.public-links a:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  color: var(--primary);
}

/* ========== MODAL ========== */
.share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.share-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.share-box {
  background: rgba(255, 255, 255, 0.9);
  padding: 2rem;
  border-radius: 20px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.share-overlay.show .share-box {
  transform: scale(1);
}

.share-box-input-wrap {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

/* ========== TOAST NOTIFICATION ========== */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: white;
  color: var(--text-main);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-left: 5px solid var(--primary);
  min-width: 300px;
  animation: slideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast.error {
  border-left-color: #ef4444;
}

.toast.success {
  border-left-color: #22c55e;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(50px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOut {
  to {
    opacity: 0;
    transform: translateX(100px);
  }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .header-inner {
    flex-direction: column;
    text-align: center;
  }

  .school-branding {
    justify-content: center;
  }

  .header-actions {
    justify-content: center;
    width: 100%;
    gap: 1rem;
  }
}

@media (max-width: 600px) {
  .main {
    padding: 0 1rem;
  }

  .card {
    padding: 1.5rem 1rem;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .header-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    border-radius: 12px;
  }

  .nav-link {
    padding: 8px 4px;
    font-size: 0.75rem;
    text-align: center;
  }
}

/* ========== ADMIN DASHBOARD & FLOW ========== */
.admin-banner {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: white;
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 2rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideInDown 0.4s ease-out;
}

.admin-banner-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}

.admin-banner i {
  color: #fbbf24;
  font-size: 1.25rem;
}

.btn-admin-link {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.4rem 1rem;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-admin-link:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

@keyframes slideInDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ========== ADMIN DASHBOARD ========== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.admin-table th,
.admin-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

.admin-table th {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.3);
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 8px;
  width: auto;
}

.btn-edit {
  background: var(--primary);
  color: white;
}

.btn-delete {
  background: #ef4444;
  color: white;
}

.btn-delete:hover {
  background: #dc2626;
}

.admin-search-card {
  padding: 1rem;
  margin-bottom: 1rem;
}

.admin-search {
  width: 100%;
  padding: 0.8rem 1.2rem;
  border-radius: 99px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
}

.overflow-x {
  overflow-x: auto;
}

@media (max-width: 768px) {

  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3) {
    display: none;
  }
}