/**
 * CatSU Dorm — Brand Theme
 * Overrides the base admin template's design tokens with the Catanduanes
 * State University identity (navy / crimson / gold) and adds a modern,
 * animated, Gen-Z-friendly interaction layer on top of the existing
 * Bootstrap component classes. Loaded after app.min.css so these rules win.
 */

/* ----------------------------------------------------------------------
   1. Brand palette — drives every component that reads --theme-* tokens
   ---------------------------------------------------------------------- */
:root,
[data-bs-theme=light] {
  --catsu-navy: #7c3aed;
  --catsu-navy-deep: #6d28d9;
  --catsu-crimson: #6d28d9;
  --catsu-gold: #f2b705;
  --catsu-gold-deep: #c99400;

  --theme-primary: #7c3aed;
  --theme-primary-rgb: 124, 58, 237;
  --theme-primary-text-emphasis: #6d28d9;
  --theme-primary-bg-subtle: #f5f3ff;
  --theme-primary-border-subtle: #ddd6fe;

  --theme-secondary: #6b7280;
  --theme-secondary-rgb: 107, 114, 128;
  --theme-secondary-text-emphasis: #374151;
  --theme-secondary-bg-subtle: #f3f4f6;
  --theme-secondary-border-subtle: #e5e7eb;

  --theme-warning: #ca8a04;
  --theme-warning-rgb: 202, 138, 4;
  --theme-warning-text-emphasis: #854d0e;
  --theme-warning-bg-subtle: #fef9c3;
  --theme-warning-border-subtle: #fde047;

  --theme-success: #7c3aed;
  --theme-success-rgb: 124, 58, 237;
  --theme-success-text-emphasis: #6d28d9;
  --theme-success-bg-subtle: #f5f3ff;
  --theme-success-border-subtle: #ddd6fe;
  --theme-info: #0ea5d6;
  --theme-info-rgb: 14, 165, 214;
  --theme-danger: #dc2626;
  --theme-danger-rgb: 220, 38, 38;

  --theme-link-color: var(--theme-primary);
  --theme-link-color-rgb: var(--theme-primary-rgb);
  --theme-link-hover-color: var(--theme-primary-text-emphasis);
  --theme-link-hover-color-rgb: 109, 40, 217;

  --theme-font-sans-serif: "Inter", "Hanken Grotesk", ui-sans-serif, sans-serif;
  --theme-body-font-family: var(--theme-font-sans-serif);
  --catsu-heading-font: "Poppins", var(--theme-font-sans-serif);

  --theme-border-radius: 0.6rem;
  --theme-border-radius-sm: 0.45rem;
  --theme-border-radius-lg: 0.9rem;
  --theme-border-radius-xl: 1.25rem;
  --theme-border-radius-xxl: 1.75rem;

  --catsu-shadow-soft: 0 8px 24px -8px rgba(13, 22, 56, 0.16);
  --catsu-shadow-lift: 0 20px 40px -14px rgba(13, 22, 56, 0.28);
  --catsu-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-bs-theme=dark] {
  --theme-primary: #4d63c9;
  --theme-primary-rgb: 77, 99, 201;
  --theme-primary-text-emphasis: #aab6ec;
  --theme-primary-bg-subtle: rgba(77, 99, 201, 0.18);
  --theme-primary-border-subtle: #2c3a80;

  --theme-secondary: #ef4763;
  --theme-secondary-rgb: 239, 71, 99;
  --theme-secondary-text-emphasis: #f6a2b0;
  --theme-secondary-bg-subtle: rgba(239, 71, 99, 0.16);

  --theme-warning: #f2b705;
  --theme-warning-rgb: 242, 183, 5;
  --theme-warning-text-emphasis: #f6d773;
  --theme-warning-bg-subtle: rgba(242, 183, 5, 0.16);

  --theme-success: #a78bfa;
  --theme-info: #38bdf8;
  --theme-danger: #f4557a;

  --theme-link-color: #92a2e6;
  --theme-link-hover-color: #ef4763;

  --catsu-shadow-soft: 0 8px 24px -8px rgba(0, 0, 0, 0.45);
  --catsu-shadow-lift: 0 20px 40px -14px rgba(0, 0, 0, 0.6);
}

/* The base template hardcodes each *-subtle badge's text color with
   !important instead of reading the --theme-* tokens above, so retinting
   the tokens alone leaves stray green/teal text behind. Override those
   leaks explicitly. */
.bg-primary-subtle { color: var(--theme-primary-text-emphasis) !important; }
.bg-success-subtle { color: var(--theme-success-text-emphasis) !important; }
.bg-secondary-subtle { color: var(--theme-secondary-text-emphasis) !important; }
.bg-warning-subtle { color: var(--theme-warning-text-emphasis) !important; }
.bg-info-subtle { color: var(--theme-info) !important; }
.bg-danger-subtle { color: var(--theme-danger) !important; }

/* Topbar + sidenav skins actually in use (data-topbar-color=light, data-menu-color=dark) */
html[data-topbar-color=light] {
  --theme-topbar-bg: rgba(255, 255, 255, 0.82);
  --theme-topbar-item-color: #4a5568;
  --theme-topbar-item-hover-color: var(--catsu-crimson);
}

html[data-menu-color=dark] {
  --theme-sidenav-bg: linear-gradient(195deg, #182a63 0%, #0d1638 78%);
  --theme-sidenav-border-color: #101c46;
  --theme-sidenav-item-color: #aab3d6;
  --theme-sidenav-item-hover-color: #ffffff;
  --theme-sidenav-item-hover-bg: rgba(255, 255, 255, 0.06);
  --theme-sidenav-item-active-color: #ffffff;
  --theme-sidenav-item-active-bg: rgba(242, 183, 5, 0.14);
}

/* ----------------------------------------------------------------------
   2. Global motion foundations
   ---------------------------------------------------------------------- */
@keyframes catsu-fade-up {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes catsu-pop-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes catsu-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes catsu-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes catsu-glow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 183, 5, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(242, 183, 5, 0); }
}

@keyframes catsu-gradient-pan {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.reveal-up {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s var(--catsu-ease), transform 0.6s var(--catsu-ease);
}
.reveal-up.in-view {
  opacity: 1;
  transform: translateY(0);
}
.reveal-up.stagger-1 { transition-delay: 0.05s; }
.reveal-up.stagger-2 { transition-delay: 0.1s; }
.reveal-up.stagger-3 { transition-delay: 0.15s; }
.reveal-up.stagger-4 { transition-delay: 0.2s; }
.reveal-up.stagger-5 { transition-delay: 0.25s; }
.reveal-up.stagger-6 { transition-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
  .reveal-up,
  .catsu-crest,
  .btn,
  .card {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ----------------------------------------------------------------------
   3. Typography
   ---------------------------------------------------------------------- */
body {
  font-family: var(--theme-body-font-family);
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--catsu-heading-font);
  letter-spacing: -0.01em;
}

/* ----------------------------------------------------------------------
   4. Cards — soft, elevated, animated entrance + hover
   ---------------------------------------------------------------------- */
.card {
  border-radius: var(--theme-border-radius-xl);
  transition: transform 0.35s var(--catsu-ease), box-shadow 0.35s var(--catsu-ease);
}

.card.shadow-sm {
  box-shadow: var(--catsu-shadow-soft) !important;
}

@media (hover: hover) {
  .content-page .card:hover {
    transform: translateY(-4px);
    box-shadow: var(--catsu-shadow-lift) !important;
  }
}

.card .avatar-md {
  transition: transform 0.3s var(--catsu-ease);
}
.card:hover .avatar-md {
  transform: scale(1.08) rotate(-4deg);
}

/* ----------------------------------------------------------------------
   5. Buttons — gradient primary, tactile hover/press
   ---------------------------------------------------------------------- */
.btn {
  border-radius: 50rem;
  font-weight: 600;
  transition: transform 0.2s var(--catsu-ease), box-shadow 0.2s var(--catsu-ease), filter 0.2s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--catsu-navy) 0%, #2c3f8f 100%);
  border-color: var(--catsu-navy);
  box-shadow: 0 6px 16px -6px rgba(22, 35, 92, 0.55);
}
.btn-primary:hover,
.btn-primary:focus {
  filter: brightness(1.08);
  box-shadow: 0 10px 22px -6px rgba(22, 35, 92, 0.6);
  transform: translateY(-1px);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--catsu-crimson) 0%, #8c0b20 100%);
  border-color: var(--catsu-crimson);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(200, 16, 46, 0.5);
}
.btn-secondary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-warning {
  color: #3a2c00;
}

.btn-outline-primary {
  border-width: 1.5px;
}

.btn-lg, .btn.btn-lg {
  border-radius: 50rem;
}

/* Small square/icon buttons keep a tighter radius so icons stay centered */
.btn-icon,
.sidenav-toggle-button,
.topnav-toggle-button {
  border-radius: var(--theme-border-radius);
}

/* ----------------------------------------------------------------------
   6. Forms — soft focus ring in brand color
   ---------------------------------------------------------------------- */
.form-control,
.form-select {
  border-radius: var(--theme-border-radius);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--catsu-navy);
  box-shadow: 0 0 0 0.2rem rgba(22, 35, 92, 0.15);
}
.input-group-text {
  border-radius: var(--theme-border-radius);
}

/* ----------------------------------------------------------------------
   7. Topbar — glass effect + brand accent line
   ---------------------------------------------------------------------- */
.app-topbar {
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--catsu-navy), var(--catsu-crimson), var(--catsu-gold)) 1;
  transition: box-shadow 0.3s ease;
}

.catsu-crest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex: 0 0 auto;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(242, 183, 5, 0.5), var(--catsu-shadow-soft);
  animation: catsu-pop-in 0.5s var(--catsu-ease) both;
}
.catsu-crest img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-topbar .catsu-crest {
  width: 34px;
  height: 34px;
  margin-right: 0.5rem;
}

/* ----------------------------------------------------------------------
   8. Sidenav — brand gradient, glowing active state, lively crest
   ---------------------------------------------------------------------- */
.sidenav-menu .logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.sidenav-menu .catsu-crest {
  width: 36px;
  height: 36px;
}

.side-nav .side-nav-item .side-nav-link {
  border-radius: var(--theme-border-radius);
  margin: 0 0.5rem;
  transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease;
}
.side-nav .side-nav-item .side-nav-link:hover {
  transform: translateX(2px);
}
.side-nav .side-nav-item .side-nav-link.active {
  position: relative;
  font-weight: 600;
}
.side-nav .side-nav-item .side-nav-link.active::before {
  content: "";
  position: absolute;
  left: -0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  border-radius: 50rem;
  background: var(--catsu-gold);
  box-shadow: 0 0 10px rgba(242, 183, 5, 0.7);
}

#user-profile-settings {
  position: relative;
}
#user-profile-settings .avatar-md {
  box-shadow: 0 0 0 3px rgba(242, 183, 5, 0.5);
  transition: box-shadow 0.3s ease;
}

/* ----------------------------------------------------------------------
   9. Badges / status chips — a touch more energy
   ---------------------------------------------------------------------- */
.badge {
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ----------------------------------------------------------------------
   10. Brand utility classes
   ---------------------------------------------------------------------- */
.text-gradient-catsu {
  background: linear-gradient(90deg, var(--catsu-navy), var(--catsu-crimson) 55%, var(--catsu-gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.bg-gradient-catsu {
  background: linear-gradient(135deg, var(--catsu-navy) 0%, #24357f 45%, var(--catsu-crimson) 100%);
  background-size: 200% 200%;
  animation: catsu-gradient-pan 12s ease infinite;
}

.catsu-seal-watermark {
  position: absolute;
  inset: auto -60px -60px auto;
  width: 260px;
  height: 260px;
  opacity: 0.08;
  filter: grayscale(1) brightness(3);
  pointer-events: none;
  user-select: none;
}

.catsu-float {
  animation: catsu-float 5s ease-in-out infinite;
}

.catsu-skeleton {
  background: linear-gradient(90deg, rgba(22, 35, 92, 0.06) 25%, rgba(22, 35, 92, 0.12) 37%, rgba(22, 35, 92, 0.06) 63%);
  background-size: 400% 100%;
  animation: catsu-shimmer 1.4s ease infinite;
  border-radius: var(--theme-border-radius);
}

/* Scrollbar theming (webkit) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: rgba(22, 35, 92, 0.25);
  border-radius: 50rem;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(22, 35, 92, 0.4);
}
