/*
 * ============================================================
 *  KopiKenangan POS — Global Stylesheet
 *  Design tokens & base styles (DESIGN.md)
 * ============================================================
 */

/* ── Google Fonts: DM Serif Display (heading) + DM Sans (body) ── */
/* Inspired by Tuku Coffee editorial serif + clean sans pairing    */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ── Design Tokens (CSS Variables) ─────────────────────── */
:root {
  /* Warna utama — Kopi Kenangan palette */
  --color-primary:    #841622; /* Merah Marun — header, navbar, tombol utama */
  --color-bg:         #FCF6F2; /* Putih Tulang — background utama */
  --color-accent:     #BD1413; /* Merah Terang — badge diskon, notif, alert */
  --color-text:       #1E1E1E; /* Hitam Soft — teks utama */
  --color-border:     #3E2723; /* Coklat Gelap — garis pemisah, teks sekunder */

  /* Warna turunan */
  --color-primary-hover:  #6a1019;
  --color-primary-light:  #f3e8e9;
  --color-white:          #ffffff;
  --color-gray-100:       #f5f5f5;
  --color-gray-200:       #e5e5e5;

  /* Tipografi — Tuku-style editorial pairing */
  --font-family:         'DM Sans', sans-serif;
  --font-family-display: 'DM Serif Display', Georgia, serif;

  --font-size-xs:   0.75rem;   /* 12px */
  --font-size-sm:   0.875rem;  /* 14px */
  --font-size-base: 1rem;      /* 16px */
  --font-size-lg:   1.125rem;  /* 18px */
  --font-size-xl:   1.25rem;   /* 20px */
  --font-size-2xl:  1.5rem;    /* 24px */
  --font-size-3xl:  1.875rem;  /* 30px */

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Border Radius */
  --radius-sm:   0.25rem;
  --radius-md:   0.5rem;
  --radius-lg:   0.75rem;
  --radius-xl:   1rem;
  --radius-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);

  /* Transition */
  --transition: 0.2s ease;
  /* Safe Area Insets (untuk notch & home bar APK/PWA) */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  /* Mencegah font scaling di Android WebView */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* Mencegah overscroll bounce di iOS */
  overscroll-behavior: none;
  /* Hapus tap highlight di Android */
  -webkit-tap-highlight-color: transparent;
}

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

a {
  color: inherit;
  text-decoration: none;
  /* Tap target minimum 44px untuk accessibility mobile */
  -webkit-tap-highlight-color: transparent;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  /* Hapus tap highlight di Android */
  -webkit-tap-highlight-color: transparent;
  /* Mencegah double-tap zoom di mobile */
  touch-action: manipulation;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  /* Mencegah auto-zoom input di iOS */
  font-size: max(16px, 1em);
}

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

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

/* ── Layout Utilities ───────────────────────────────────── */
.container {
  width: 100%;
  max-width: 480px; /* Mobile-first max width */
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 768px) {
  .container {
    max-width: 960px;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 1200px;
  }
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 500;
  transition: background-color var(--transition), transform var(--transition);
}

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

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

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

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

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

.btn-outline:hover {
  background-color: var(--color-primary-light);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* ── Badge ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.badge-accent {
  background-color: var(--color-accent);
  color: var(--color-white);
}

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

/* ── Card ───────────────────────────────────────────────── */
.card {
  background-color: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* ── Form Elements ──────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-border);
  margin-bottom: var(--space-2);
}

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-white);
  transition: border-color var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* ── Alert / Notification ───────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-4);
}

.alert-success {
  background-color: #d4edda;
  color: #155724;
  border-left: 4px solid #28a745;
}

.alert-error {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border-left: 4px solid var(--color-accent);
}

.alert-info {
  background-color: #d1ecf1;
  color: #0c5460;
  border-left: 4px solid #17a2b8;
}

/* ── Divider ────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--color-gray-200);
  margin: var(--space-4) 0;
}

/* ── Loading Spinner ────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-gray-200);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Toast Notification ─────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background-color: var(--color-text);
  color: var(--color-white);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
}

/* ── Responsive Utilities ───────────────────────────────── */

/* Mobile-first show/hide helpers */
.hide-mobile  { display: none !important; }
.show-mobile  { display: block !important; }

@media (min-width: 640px) {
  .hide-sm      { display: none !important; }
  .show-sm      { display: block !important; }
}

@media (min-width: 768px) {
  .hide-mobile  { display: block !important; }
  .show-mobile  { display: none !important; }
  .hide-md      { display: none !important; }
  .show-md      { display: block !important; }
}

@media (min-width: 1024px) {
  .hide-lg      { display: none !important; }
  .show-lg      { display: block !important; }
}

/* Safe area padding utilities */
.safe-top    { padding-top: env(safe-area-inset-top, 0px); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }
.safe-left   { padding-left: env(safe-area-inset-left, 0px); }
.safe-right  { padding-right: env(safe-area-inset-right, 0px); }

/* Touch-friendly tap target (min 44x44px) */
.touch-target {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Utility Classes ───────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--color-border); }
.text-primary { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.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); }
.mb-4 { margin-bottom: var(--space-4); }

/* ── Animations ────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.animate-fadeInUp {
  animation: fadeInUp 0.4s ease forwards;
}

/* ── Dark Mode Design Tokens ────────────────────────────── */
[data-theme="dark"],
.dark-theme {
  --color-bg:            #161311;
  --color-text:          #f4eee9;
  --color-border:        #7a6b63;
  --color-white:         #241d1a;
  --color-gray-100:      #2c2420;
  --color-gray-200:      #3d322d;
  --color-primary:       #a82433;
  --color-primary-hover: #c43142;
  --color-primary-light: #33191d;
}

[data-theme="dark"] body {
  background-color: #161311;
  color: #f4eee9;
}

[data-theme="dark"] .card {
  background-color: #241d1a;
  border-color: #3d322d;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .modal {
  background-color: #241d1a;
  color: #f4eee9;
}

[data-theme="dark"] .form-input {
  background-color: #1c1715;
  border-color: #473a34;
  color: #f4eee9;
}

[data-theme="dark"] .form-input:focus {
  border-color: #a82433;
  box-shadow: 0 0 0 3px rgba(168, 36, 51, 0.25);
}

/* ── Theme Toggle Button (🌙 / ☀️) ────────────────────────── */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.06);
}

.theme-toggle-btn:active {
  transform: scale(0.94);
}

.theme-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Landing specific theme toggle button */
.landing-nav .theme-toggle-btn {
  border-color: #e5d8cc;
  background: #ffffff;
  color: #841622;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.landing-nav .theme-toggle-btn:hover {
  background: #fdf5f5;
  border-color: #841622;
}

[data-theme="dark"] .landing-nav .theme-toggle-btn {
  border-color: #4a3c35;
  background: #2b221e;
  color: #f4eee9;
}
