/* ============================================
   BintangKu – Base Styles
   Reset, Typography, Global Utilities
   ============================================ */

/* ─── Modern Reset ─── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

ul, ol {
  list-style: none;
}

/* ─── Typography ─── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}

h1 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-extrabold);
}
h2 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}
h3 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
}
h4 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}
h5 {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
}
h6 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
}

p {
  line-height: var(--line-height-relaxed);
  color: var(--color-text-secondary);
}

small {
  font-size: var(--font-size-sm);
}

strong {
  font-weight: var(--font-weight-bold);
}

/* ─── Selection ─── */
::selection {
  background-color: var(--color-primary);
  color: var(--color-text-on-primary);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* ─── Focus Visible ─── */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─── App Layout ─── */
#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

#page-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.page {
  flex: 1;
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: var(--space-4);
  animation: pageIn 0.35s ease;
}

.page-with-bottom-nav {
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-4) + env(safe-area-inset-bottom, 0px)) !important;
}

.page-with-sidebar {
  margin-left: var(--sidebar-width);
}

/* ─── Container ─── */
.container {
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* ─── Grid Utilities ─── */
.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ─── Flex Utilities ─── */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-start {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

/* ─── Text Utilities ─── */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-accent { color: var(--color-primary-dark); }
.text-success { color: var(--color-accent-green-dark); }
.text-danger { color: var(--color-accent-red-dark); }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }

.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }
.font-extrabold { font-weight: var(--font-weight-extrabold); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Spacing Utilities ─── */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

/* ─── Button Base ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
  min-height: 48px;
  min-width: 48px;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::after {
  opacity: 0.1;
}

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

.btn-primary {
  background: var(--color-primary-gradient);
  color: var(--color-text-on-primary);
  box-shadow: var(--shadow-md), var(--shadow-glow-primary);
}

.btn-primary:hover {
  box-shadow: var(--shadow-lg), 0 0 32px rgba(255, 204, 51, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-secondary-gradient);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-md), var(--shadow-glow-secondary);
}

.btn-secondary:hover {
  box-shadow: var(--shadow-lg), 0 0 32px rgba(124, 92, 252, 0.4);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--color-accent-green) 0%, var(--color-accent-green-dark) 100%);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-md), var(--shadow-glow-green);
}

.btn-danger {
  background: linear-gradient(135deg, var(--color-accent-red) 0%, var(--color-accent-red-dark) 100%);
  color: var(--color-text-inverse);
}

.btn-outline {
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.btn-outline:hover {
  border-color: var(--color-primary);
  background: var(--color-bg-warm);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background: var(--color-bg-warm);
  color: var(--color-text-primary);
}

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  min-height: 36px;
  border-radius: var(--radius-md);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--font-size-lg);
  min-height: 56px;
  border-radius: var(--radius-xl);
}

.btn-icon {
  padding: var(--space-3);
  border-radius: var(--radius-full);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ─── Card Base ─── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-interactive:active {
  transform: translateY(0);
}

/* ─── Input Base ─── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.input-group label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
}

.input-field {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  min-height: 48px;
  transition: all var(--transition-base);
}

.input-field:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 204, 51, 0.15);
}

.input-field::placeholder {
  color: var(--color-text-tertiary);
}

.input-field.error {
  border-color: var(--color-accent-red);
}

.input-error {
  font-size: var(--font-size-xs);
  color: var(--color-accent-red);
  margin-top: var(--space-1);
}

select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B6490' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

textarea.input-field {
  min-height: 100px;
  resize: vertical;
}

/* ─── Badge ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-primary {
  background: rgba(255, 204, 51, 0.15);
  color: var(--color-primary-dark);
}

.badge-secondary {
  background: rgba(124, 92, 252, 0.15);
  color: var(--color-secondary);
}

.badge-success {
  background: rgba(52, 211, 153, 0.15);
  color: var(--color-accent-green-dark);
}

.badge-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--color-accent-red-dark);
}

.badge-warning {
  background: rgba(251, 146, 60, 0.15);
  color: #C2410C;
}

/* ─── Chip / Tag ─── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip:hover {
  border-color: var(--color-primary);
  background: var(--color-bg-warm);
}

.chip.active {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  border-color: var(--color-primary);
}

/* ─── Divider ─── */
.divider {
  height: 1px;
  background: var(--color-border-light);
  border: none;
  margin: var(--space-4) 0;
}

/* ─── Avatar ─── */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-inverse);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-sm { width: 36px; height: 36px; font-size: var(--font-size-base); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--font-size-2xl); }
.avatar-xl { width: 96px; height: 96px; font-size: var(--font-size-4xl); }
.avatar-2xl { width: 120px; height: 120px; font-size: 4rem; }

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ─── Overlay / Backdrop ─── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 75, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-modal-backdrop);
  animation: fadeIn 0.2s ease;
}

/* ─── Modal ─── */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-modal);
  max-width: 440px;
  width: calc(100% - var(--space-8));
  animation: modalIn 0.3s var(--transition-bounce);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.modal-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: var(--font-size-lg);
  color: var(--color-text-tertiary);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--color-bg-warm);
  color: var(--color-text-primary);
}

/* ─── Section Header ─── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.section-link {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-secondary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.section-link:hover {
  color: var(--color-secondary-dark);
}

/* ─── Responsive ─── */
@media (min-width: 600px) {
  .page {
    padding: var(--space-6);
  }

  h1 { font-size: var(--font-size-4xl); }
  h2 { font-size: var(--font-size-3xl); }
}

@media (min-width: 1024px) {
  .page {
    padding: var(--space-8);
  }

  .hide-desktop { display: none !important; }
}

@media (max-width: 599px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 600px) and (max-width: 1023px) {
  .hide-tablet { display: none !important; }
}
