/* Custom styles for SIPP Ibnul Qoyyim */

body {
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    'Roboto',
    'Oxygen',
    'Ubuntu',
    'Cantarell',
    'Fira Sans',
    'Droid Sans',
    'Helvetica Neue',
    sans-serif;
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--foreground);
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

/* Dark mode body styles */
.dark body,
html.dark body {
  background: var(--background);
  color: var(--foreground);
}

* {
  box-sizing: border-box;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Table styles */
table {
  border-collapse: collapse;
}

/* Button hover effects */
button:hover,
a.btn:hover {
  opacity: 0.9;
}

/* Form elements */
input,
select,
textarea {
  font-family: inherit;
}

/* ============================================
   MOBILE-FIRST RESPONSIVE STYLES
   Target: 412 x 915 display (Pixel 7)
   ============================================ */

/* App Shell */
.app-shell {
  min-height: 100vh;
  position: relative;
  background: var(--background);
}

.app-shell__scrim {
  position: fixed;
  inset: 0;
  border: none;
  background: rgba(15, 23, 42, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 40;
}

.app-shell__sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(85vw, 20rem);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform 0.18s ease;
  z-index: 50;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
}

.app-shell__sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

.app-shell__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.app-shell__brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.9rem;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.app-shell__brand-title,
.app-shell__brand-subtitle {
  display: block;
}

.app-shell__brand-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--foreground);
}

.app-shell__brand-subtitle {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.app-shell__close-button,
.app-shell__menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.app-shell__close-button:hover,
.app-shell__menu-button:hover {
  background: var(--muted);
}

.app-shell__sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.app-nav__section + .app-nav__section {
  margin-top: 1.25rem;
}

.app-nav__section-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.55rem;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.app-nav__section-title {
  padding: 0 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.app-nav__section-chevron {
  flex-shrink: 0;
  color: var(--muted-foreground);
  transition: transform 0.2s ease;
}

.app-nav__section[data-section-state='closed'] .app-nav__section-chevron {
  transform: rotate(-90deg);
}

.app-nav__items {
  display: grid;
  gap: 0.35rem;
}

.app-nav__link,
.app-nav__action,
.app-footer-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--foreground);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.app-nav__link:hover,
.app-nav__action:hover,
.app-footer-button:hover {
  background: var(--muted);
  border-color: var(--border);
}

.app-nav__link.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.app-nav__action:disabled {
  opacity: 0.7;
  cursor: wait;
}

.app-nav__status {
  margin: 0.45rem 0.3rem 0;
  font-size: 0.78rem;
  color: var(--muted-foreground);
}

.app-nav__status[data-state='success'] {
  color: #0f766e;
}

.app-nav__status[data-state='error'] {
  color: var(--destructive);
}

.dark .app-nav__status[data-state='success'] {
  color: #5eead4;
}

.app-shell__sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 1rem;
}

.app-account {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.2rem 0.1rem;
}

.app-account__avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--muted);
  border: 1px solid var(--border);
}

.app-account__avatar--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.app-account__copy {
  min-width: 0;
}

.app-account__name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--foreground);
}

.app-account__email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--muted-foreground);
}

.app-shell__footer-actions {
  display: grid;
  gap: 0.55rem;
}

.app-shell__utility-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.app-footer-button {
  gap: 0.7rem;
}

.app-footer-button--icon {
  justify-content: center;
  width: 2.75rem;
  min-width: 2.75rem;
  padding: 0;
}

.app-footer-button__icon {
  flex-shrink: 0;
}

.app-footer-button--icon[data-state='pending'] svg {
  animation: spin 1s linear infinite;
}

.app-footer-button--danger {
  color: var(--destructive);
}

.app-nav__status--footer {
  margin: 0;
}

.app-shell__topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1rem 0.9rem;
  background: color-mix(in srgb, var(--background) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.app-shell__topbar-copy {
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}

.app-shell__topbar-brand {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  text-decoration: none;
}

.app-shell__topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
}

.app-shell__content {
  min-width: 0;
  padding: 1rem 1rem 1.5rem;
}

.app-shell__content-inner {
  max-width: 1180px;
  margin: 0 auto;
}

.app-shell[data-nav-state='open'] .app-shell__scrim {
  opacity: 1;
  pointer-events: auto;
}

.app-shell[data-nav-state='open'] .app-shell__sidebar,
.app-shell[data-nav-state='desktop'] .app-shell__sidebar {
  transform: translateX(0);
}

/* Page Layout */
.page-header {
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  color: var(--foreground);
}

.page-subtitle {
  color: var(--muted-foreground);
  margin: 0;
  font-size: 0.875rem;
}

/* Cards */
.card {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--card);
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.summary-card {
  padding: 1rem;
  border-radius: 0.5rem;
  text-align: center;
  background: var(--summary-bg, var(--card));
  border: 1px solid var(--summary-border, var(--border));
  color: var(--summary-fg, var(--foreground));
}

.summary-card-blue {
  --summary-bg: var(--summary-blue-bg);
  --summary-fg: var(--summary-blue-fg);
  --summary-muted: var(--summary-blue-muted);
}

.summary-card-pink {
  --summary-bg: var(--summary-pink-bg);
  --summary-fg: var(--summary-pink-fg);
  --summary-muted: var(--summary-pink-muted);
}

.summary-card-green {
  --summary-bg: var(--summary-green-bg);
  --summary-fg: var(--summary-green-fg);
  --summary-muted: var(--summary-green-muted);
}

.summary-card-yellow {
  --summary-bg: var(--summary-yellow-bg);
  --summary-fg: var(--summary-yellow-fg);
  --summary-muted: var(--summary-yellow-muted);
}

.summary-label {
  font-size: 0.75rem;
  color: var(--summary-muted, var(--muted-foreground));
  margin-bottom: 0.25rem;
}

.summary-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--summary-fg, var(--foreground));
}

/* Data Tables */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 0.75rem 0.5rem;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
  background: var(--muted);
}

/* Mobile Data Cards */
.mobile-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mobile-data-card {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: var(--card);
}

.mobile-card-header {
  font-weight: 600;
  font-size: 0.875rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--primary);
}

.mobile-card-row {
  display: flex;
  justify-content: space-between;
  padding: 0.375rem 0;
  font-size: 0.875rem;
}

.mobile-card-label {
  color: var(--muted-foreground);
}

.mobile-card-value {
  font-weight: 500;
}

.mobile-card-total {
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  font-weight: 600;
}

.mobile-card-total .mobile-card-label,
.mobile-card-total .mobile-card-value {
  font-weight: 600;
  color: var(--foreground);
}

/* Form Styles */
.form-container {
  max-width: 100%;
}

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--foreground);
}

.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--card);
  color: var(--foreground);
}

/* Readonly / disabled field variant */
.form-input-readonly {
  display: block;
  width: 100%;
  height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--muted);
  color: var(--muted-foreground);
  box-sizing: border-box;
  cursor: default;
}

.form-textarea {
  height: auto;
  min-height: 6rem;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.375rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  transition: opacity 0.2s ease;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--muted);
}

.btn-success {
  background: var(--chart-1);
  color: var(--primary-foreground);
}

.btn-success:hover {
  opacity: 0.9;
}

.btn-danger {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
}

.badge-success {
  background: #2c6ecb;
  color: #ffffff;
}

.badge-danger {
  background: #e87c0c;
  color: #ffffff;
}

.badge-blue {
  background: var(--primary);
  color: var(--primary-foreground);
}

.badge-gray {
  background: var(--muted);
  color: var(--muted-foreground);
}

/* Access permission badges - Polaris semantic colors */
.badge-access-santri {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  background: #f1f8f5;
  color: #006540;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
}
.dark .badge-access-santri {
  background: #1a3828;
  color: #7dd6b8;
}

.badge-access-santriwati {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  background: #ebf9fc;
  color: #005873;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
}
.dark .badge-access-santriwati {
  background: #0d2830;
  color: #7fd8e8;
}

/* Checkbox label text */
.checkbox-label {
  font-size: 0.875rem;
  color: var(--foreground);
}

/* Student Name Link */
.student-name-link {
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

.student-name-link:hover {
  text-decoration: underline;
}

/* Action Buttons Group */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.action-buttons .btn {
  width: auto;
  flex: 1 1 auto;
  min-width: 120px;
}

/* Student Info Card */
.student-info-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.student-info-section {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.student-info-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.info-row {
  display: flex;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.info-label {
  color: var(--muted-foreground);
  min-width: 100px;
  flex-shrink: 0;
}

.info-value {
  font-weight: 500;
}

/* Financial Summary */
.financial-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1rem;
}

.financial-card {
  padding: 0.75rem;
  border-radius: 0.375rem;
  text-align: center;
  border: 1px solid var(--border);
}

.financial-card-label {
  font-size: 0.625rem;
  color: var(--foreground);
  opacity: 0.7;
  margin-bottom: 0.25rem;
}

.financial-card-value {
  font-size: 0.875rem;
  font-weight: 600;
}

/* Financial card color variants — Polaris semantic colors */
.financial-card-blue {
  background: #ebf9fc;
  color: #003b4d;
}
.dark .financial-card-blue {
  background: #0d2830;
  color: #7fd8e8;
}
.financial-card-blue .financial-card-label {
  color: #003b4d;
}
.dark .financial-card-blue .financial-card-label {
  color: #7fd8e8;
}

.financial-card-amber {
  background: #fff5ea;
  color: #4a3200;
}
.dark .financial-card-amber {
  background: #2c1f0a;
  color: #ffcc7d;
}
.financial-card-amber .financial-card-label {
  color: #4a3200;
}
.dark .financial-card-amber .financial-card-label {
  color: #ffcc7d;
}

.financial-card-green {
  background: #f1f8f5;
  color: #003b2b;
}
.dark .financial-card-green {
  background: #0d2820;
  color: #7dd6b8;
}
.financial-card-green .financial-card-label {
  color: #003b2b;
}
.dark .financial-card-green .financial-card-label {
  color: #7dd6b8;
}

.financial-card-red {
  background: #fff4f4;
  color: #7a1d00;
}
.dark .financial-card-red {
  background: #2c1210;
  color: #ff9b8e;
}
.financial-card-red .financial-card-label {
  color: #7a1d00;
}
.dark .financial-card-red .financial-card-label {
  color: #ff9b8e;
}

.financial-card-neutral {
  background: #f1f2f3;
  color: #303030;
}
.dark .financial-card-neutral {
  background: #26282b;
  color: #e3e3e3;
}
.financial-card-neutral .financial-card-label {
  color: #303030;
}
.dark .financial-card-neutral .financial-card-label {
  color: #e3e3e3;
}

/* Search Input */
.search-container {
  margin-bottom: 1rem;
}

.search-input {
  width: 100%;
  height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--card);
}

/* Back Link */
.back-link {
  display: none !important;
}

.back-link:hover {
  color: var(--muted-foreground);
}

/* Desktop/Mobile Visibility */
.desktop-only {
  display: none;
}

.mobile-only {
  display: block;
}

/* ============================================
   TABLET & DESKTOP STYLES (768px+)
   ============================================ */
@media (min-width: 768px) {
  .page-title {
    font-size: 1.875rem;
  }

  .card {
    padding: 1.5rem;
  }

  .summary-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-value {
    font-size: 1.25rem;
  }

  .form-actions {
    flex-direction: row;
    justify-content: flex-start;
  }

  .btn {
    width: auto;
  }

  .action-buttons .btn {
    flex: none;
    min-width: auto;
  }

  .student-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  .student-info-section {
    border-bottom: none;
    padding-bottom: 0;
  }

  .financial-summary {
    grid-template-columns: repeat(4, 1fr);
  }

  .financial-card-label {
    font-size: 0.75rem;
  }

  .financial-card-value {
    font-size: 1rem;
  }

  .desktop-only {
    display: block;
  }

  .mobile-only {
    display: none;
  }
}

/* Large Desktop (1024px+) */
@media (min-width: 1024px) {
  .app-shell {
    display: grid;
    grid-template-columns: 18.5rem minmax(0, 1fr);
    align-items: start;
  }

  .app-shell__scrim {
    display: none;
  }

  .app-shell__sidebar {
    position: sticky;
    top: 0;
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 100%;
    height: 100vh;
    box-shadow: none;
  }

  .app-shell__close-button,
  .app-shell__menu-button {
    display: none;
  }

  .app-shell__topbar {
    grid-column: 2;
    padding: 1.25rem 2rem 1rem;
  }

  .app-shell__content {
    grid-column: 2;
    padding: 0 2rem 2rem;
  }

  main.container {
    padding: 2rem;
  }
}

/* ============================================
   DARK MODE STYLES
   ============================================ */

.dark .card {
  border-color: #1e293b;
}

/* ============================================
   LOGIN PAGE STYLES
   ============================================ */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
}

.login-container {
  width: 100%;
  max-width: 28rem;
  padding: 1rem;
}

.login-card {
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 2rem;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--foreground);
}

.login-subtitle {
  color: var(--muted-foreground);
  margin-bottom: 1.5rem;
}

.login-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.375rem;
  background: var(--primary);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary-foreground);
  text-decoration: none;
  transition: background-color 0.2s;
}

.login-button:hover {
  opacity: 0.9;
}

/* Dark mode login page - no longer needed as variables handle it */

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */

.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease,
    transform 0.3s ease,
    background-color 0.2s ease;
  z-index: 1000;
}

.back-to-top:hover {
  opacity: 0.9;
  transform: translateY(0) scale(1.05);
}

.back-to-top:active {
  transform: translateY(0) scale(0.95);
}

.back-to-top.visible {
  opacity: 0.7;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top svg {
  width: 1.5rem;
  height: 1.5rem;
}

/* Mobile adjustments for back to top button */
@media (max-width: 768px) {
  .back-to-top {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 2.75rem;
    height: 2.75rem;
  }

  .back-to-top svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}
