/* ==========================================================================
   Customer Membership System - Modern CSS Design System
   Font: Prompt & Kanit (Google Fonts)
   ========================================================================== */

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

:root {
  /* Primary Color Palette */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --primary-dark: #3730a3;

  /* Status Colors */
  --status-active: #10b981;
  --status-active-bg: #d1fae5;
  --status-active-text: #065f46;

  --status-expiring: #f59e0b;
  --status-expiring-bg: #fef3c7;
  --status-expiring-text: #92400e;

  --status-expired: #ef4444;
  --status-expired-bg: #fee2e2;
  --status-expired-text: #991b1b;

  --status-cancelled: #6b7280;
  --status-cancelled-bg: #f3f4f6;
  --status-cancelled-text: #374151;

  /* Neutral Dark Theme / Slate */
  --bg-gradient-start: #0f172a;
  --bg-gradient-end: #1e293b;
  --card-bg: rgba(30, 41, 59, 0.75);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  --input-bg: rgba(15, 23, 42, 0.6);
  --input-border: rgba(255, 255, 255, 0.15);
  --input-focus-border: #6366f1;

  --modal-bg: #1e293b;
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  color: var(--text-main);
  min-height: 100vh;
  padding: 2rem 1.5rem;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
}

/* Header & Nav */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.brand-icon svg {
  width: 28px;
  height: 28px;
  color: #fff;
}

.brand-title h1 {
  font-size: 1.75rem;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

.header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Glassmorphic Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.total { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.stat-icon.active { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.stat-icon.expiring { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.stat-icon.expired { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.stat-icon.cancelled { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }

.stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: 'Kanit', sans-serif;
}

.stat-info .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Alert Banner */
.alert-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.15));
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.alert-banner-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-banner-content svg {
  color: #fbbf24;
  flex-shrink: 0;
}

/* Action Bar & Controls */
.controls-bar {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-filter-row {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

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

.search-box input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

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

.search-box svg {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.filter-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'Prompt', sans-serif;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4338ca, #4f46e5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--card-border);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #ffffff;
}
.btn-success:hover {
  background: linear-gradient(135deg, #047857, #059669);
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #ffffff;
}
.btn-warning:hover {
  background: linear-gradient(135deg, #b45309, #d97706);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #ffffff;
}
.btn-danger:hover {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
}

.btn-info {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #ffffff;
}
.btn-info:hover {
  background: linear-gradient(135deg, #0369a1, #0284c7);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.825rem;
  border-radius: var(--radius-sm);
}

/* Data Table Container */
.table-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.925rem;
}

.data-table th {
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
}

.data-table td {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-active {
  background: var(--status-active-bg);
  color: var(--status-active-text);
}
.badge-active .badge-dot { background: var(--status-active); }

.badge-expiring {
  background: var(--status-expiring-bg);
  color: var(--status-expiring-text);
  animation: pulse-border 2s infinite;
}
.badge-expiring .badge-dot { background: var(--status-expiring); }

.badge-expired {
  background: var(--status-expired-bg);
  color: var(--status-expired-text);
}
.badge-expired .badge-dot { background: var(--status-expired); }

.badge-cancelled {
  background: var(--status-cancelled-bg);
  color: var(--status-cancelled-text);
}
.badge-cancelled .badge-dot { background: var(--status-cancelled); }

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.action-buttons {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

/* PASSCODE / LOGIN OVERLAY STYLES */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.95), rgba(2, 6, 23, 0.98));
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 1.5rem;
}

.login-overlay:not(.active) {
  display: none;
}

.login-card {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  animation: fadeInDown 0.4s ease forwards;
}

.login-icon {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem auto;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
  color: #fff;
}

.login-card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.passcode-input-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.passcode-input-group input {
  background: var(--input-bg);
  border: 2px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  color: var(--text-main);
  font-size: 1.25rem;
  letter-spacing: 4px;
  text-align: center;
  outline: none;
  font-family: monospace, 'Prompt', sans-serif;
  transition: border-color var(--transition-fast);
}

.passcode-input-group input:focus {
  border-color: var(--input-focus-border);
}

.passcode-input-group input.shake {
  animation: shake 0.4s ease;
  border-color: #ef4444;
}

.login-error {
  margin-top: 1rem;
  color: #f87171;
  font-size: 0.85rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.6rem;
  border-radius: var(--radius-sm);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--modal-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition-normal);
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
}

.modal-header h3 {
  font-size: 1.25rem;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.4);
}

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

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

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.9rem;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: 'Prompt', sans-serif;
  outline: none;
  transition: border-color var(--transition-fast);
}

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

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* Renewal History Timeline */
.timeline {
  position: relative;
  padding-left: 1.5rem;
  margin-top: 1rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--card-border);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.5rem;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--modal-bg);
}

.timeline-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.timeline-content {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
}

.timeline-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #818cf8;
  margin-bottom: 0.25rem;
}

/* Message Template Box */
.notice-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px dashed var(--input-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: monospace, sans-serif;
  font-size: 0.9rem;
  white-space: pre-wrap;
  color: #38bdf8;
  margin-bottom: 1rem;
  line-height: 1.6;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--primary);
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.3s ease forwards;
}

.toast.success { border-left-color: var(--status-active); }
.toast.warning { border-left-color: var(--status-expiring); }
.toast.error { border-left-color: var(--status-expired); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  body { padding: 1rem 0.75rem; }
  .form-grid { grid-template-columns: 1fr; }
  .search-filter-row { flex-direction: column; align-items: stretch; }
  .search-box { min-width: 100%; }
}
