/* ==========================================================================
   JAMNAM24 (จำนำ24) - LUXURY DARK PAWNSHOP DESIGN SYSTEM & RWD STYLES
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg-dark: #0a0d14;
  --bg-card: #121824;
  --bg-card-hover: #1a2333;
  --bg-card-border: #242f45;
  --bg-glass: rgba(18, 24, 36, 0.85);

  --text-primary: #f0f4fd;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-gold: #f59e0b;
  --accent-gold-hover: #d97706;
  --accent-gold-glow: rgba(245, 158, 11, 0.25);

  --status-safe: #10b981;
  --status-safe-bg: rgba(16, 185, 129, 0.15);
  --status-due: #f59e0b;
  --status-due-bg: rgba(245, 158, 11, 0.15);
  --status-grace: #ef4444;
  --status-grace-bg: rgba(239, 68, 68, 0.15);
  --status-forfeited: #8b5cf6;
  --status-forfeited-bg: rgba(139, 92, 246, 0.15);
  --status-redeemed: #06b6d4;
  --status-redeemed-bg: rgba(6, 182, 212, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-main: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 8px 25px -5px rgba(245, 158, 11, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(245, 158, 11, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.04) 0%, transparent 40%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ==========================================================================
   HEADER & NAVBAR
   ========================================================================== */
.header-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bg-card-border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-badge {
  background: linear-gradient(135deg, var(--accent-gold), #b45309);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-gold);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
}

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

.nav-btn.active {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--accent-gold);
  font-weight: 600;
}

.nav-intake-btn {
  background: linear-gradient(135deg, var(--accent-gold), #d97706);
  color: #000;
  font-weight: 600;
  border: none;
  box-shadow: var(--shadow-gold);
}

.nav-intake-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* ==========================================================================
   MAIN CONTAINER & SECTIONS
   ========================================================================== */
.main-wrapper {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.app-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.app-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   STAT CARDS & WALLET HEADERS
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-main);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(245, 158, 11, 0.3);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Wallet Card Accents */
.stat-working {
  border-left: 4px solid var(--accent-gold);
}
.stat-operating {
  border-left: 4px solid var(--status-safe);
}
.stat-tiedup {
  border-left: 4px solid var(--status-forfeited);
}

/* ==========================================================================
   FILTER TABS & CONTROLS
   ========================================================================== */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.status-tabs {
  display: flex;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-card-border);
  gap: 4px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

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

.tab-btn.active {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.tab-count {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
}

.search-box {
  position: relative;
  min-width: 260px;
}

.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  padding: 10px 16px 10px 40px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-gold);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ==========================================================================
   ASSETS GRID & CARDS
   ========================================================================== */
.assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.asset-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-main);
}

.asset-card:hover {
  border-color: rgba(245, 158, 11, 0.35);
  transform: translateY(-2px);
}

.asset-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ticket-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.1);
  border: 1px dashed rgba(245, 158, 11, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-badge.safe {
  background: var(--status-safe-bg);
  color: var(--status-safe);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.due {
  background: var(--status-due-bg);
  color: var(--status-due);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.grace {
  background: var(--status-grace-bg);
  color: var(--status-grace);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.forfeited {
  background: var(--status-forfeited-bg);
  color: var(--status-forfeited);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.status-badge.redeemed {
  background: var(--status-redeemed-bg);
  color: var(--status-redeemed);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.asset-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.asset-type-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.asset-details-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.detail-row {
  display: flex;
  justify-content: space-between;
}

.detail-label {
  color: var(--text-muted);
}

.detail-val {
  color: var(--text-primary);
  font-weight: 500;
}

.principal-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  padding: 12px 16px;
  border-radius: var(--radius-md);
}

.principal-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.principal-amount {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.asset-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-extend {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-extend:hover {
  background: var(--accent-gold);
  color: #000;
}

.btn-redeem {
  background: rgba(16, 185, 129, 0.15);
  color: var(--status-safe);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-redeem:hover {
  background: var(--status-safe);
  color: #000;
}

.btn-forfeit {
  background: rgba(239, 68, 68, 0.15);
  color: var(--status-grace);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-forfeit:hover {
  background: var(--status-grace);
  color: #fff;
}

.btn-print {
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  border: 1px solid var(--bg-card-border);
  flex: 0 0 42px;
}

.btn-print:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* ==========================================================================
   FORM & INTAKE LAYOUT
   ========================================================================== */
.form-container {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-main);
  max-width: 900px;
  margin: 0 auto;
}

.form-header {
  margin-bottom: 28px;
  border-bottom: 1px solid var(--bg-card-border);
  padding-bottom: 16px;
}

.form-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-control {
  background: var(--bg-dark);
  border: 1px solid var(--bg-card-border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  border-color: var(--accent-gold);
}

/* OCR Camera & Upload Zone */
.ocr-drop-zone {
  border: 2px dashed rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.03);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.ocr-drop-zone:hover {
  background: rgba(245, 158, 11, 0.08);
  border-color: var(--accent-gold);
}

.ocr-preview-img {
  max-height: 180px;
  border-radius: var(--radius-md);
  margin-top: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  border: 2px solid var(--accent-gold);
}

.pdpa-notice {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.8rem;
  color: var(--status-safe);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-main);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

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

/* ==========================================================================
   PAPERANG 57mm THERMAL RECEIPT STYLES
   ========================================================================== */
.ticket-paperang {
  background: #ffffff;
  color: #000000;
  width: 280px; /* Standard 57mm Thermal printer preview width */
  margin: 0 auto;
  padding: 16px 12px;
  font-family: 'Prompt', 'Courier New', monospace;
  border-radius: 4px;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  font-size: 11px;
  line-height: 1.4;
}

.paperang-header {
  text-align: center;
  border-bottom: 1px dashed #000;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.paperang-title {
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
}

.paperang-subtitle {
  font-size: 10px;
  font-weight: 600;
}

.paperang-ticket-no {
  font-size: 14px;
  font-weight: 700;
  margin: 4px 0;
}

.paperang-row {
  display: flex;
  justify-content: space-between;
  margin: 4px 0;
}

.paperang-row.bold {
  font-weight: 700;
  font-size: 12px;
}

.paperang-divider {
  border-top: 1px dashed #000;
  margin: 8px 0;
}

.paperang-legal {
  font-size: 8px;
  color: #333;
  line-height: 1.2;
  margin-top: 8px;
  text-align: justify;
}

.paperang-signature {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  text-align: center;
  font-size: 9px;
}

.sig-line {
  border-top: 1px solid #000;
  width: 110px;
  margin-top: 24px;
}

/* Printable layout optimization */
@media print {
  body * {
    visibility: hidden;
  }
  .ticket-paperang, .ticket-paperang * {
    visibility: visible;
  }
  .ticket-paperang {
    position: absolute;
    left: 0;
    top: 0;
    width: 57mm;
    box-shadow: none;
    padding: 0;
  }
}

/* Responsive Rules */
@media (max-width: 768px) {
  .header-nav {
    padding: 12px 16px;
  }
  .nav-links {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--bg-card-border);
    padding: 8px 12px;
    justify-content: space-around;
    z-index: 150;
  }
  .nav-btn span {
    display: none;
  }
  .nav-btn {
    padding: 12px;
    border-radius: var(--radius-lg);
  }
  .main-wrapper {
    padding-bottom: 100px;
  }
}
