/* ── DESIGN SYSTEM & CONSTANTS ── */
:root {
  --bg-primary: #06060a;
  --bg-secondary: #0a0a10;
  --bg-card: rgba(13, 13, 22, 0.55);
  --bg-card-hover: rgba(22, 22, 36, 0.7);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text-primary: #f3f3f6;
  --text-secondary: #8c8c9e;
  --text-muted: #575765;
  
  --primary-color: #10b981;
  --primary-glow: rgba(16, 185, 129, 0.15);
  --accent-color: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --danger-color: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.15);
  --warning-color: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.15);
  --info-color: #3b82f6;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── BASE RESET ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

.font-syne {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
}

/* Ambient glow backgrounds */
.glow-sphere {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.25;
  pointer-events: none;
}
.glow-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--accent-color) 0%, transparent 80%);
  top: -100px;
  right: -50px;
}
.glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--primary-color) 0%, transparent 80%);
  bottom: -150px;
  left: -100px;
}

/* ── UTILITIES & COMPONENTS ── */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.glass-card:hover {
  border-color: var(--border-hover);
}

.hidden {
  display: none !important;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  white-space: nowrap;
}

.btn-icon svg, .btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #06060a;
}
.btn-primary:hover {
  background-color: #0ea572;
  box-shadow: 0 0 16px var(--primary-glow);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
}

.btn-danger {
  background-color: var(--danger-color);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
  box-shadow: 0 0 16px var(--danger-glow);
  transform: translateY(-1px);
}
.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.btn-block {
  width: 100%;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-active {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--primary-color);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-suspended {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--warning-color);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-expired {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-plan {
  background-color: rgba(99, 102, 241, 0.1);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 10px 14px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: var(--transition);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent-color);
  background-color: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.select-wrapper {
  position: relative;
}

.input-hint {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── LOGIN SCREEN UI ── */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(4, 4, 7, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-badge-icon {
  width: 52px;
  height: 52px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.login-badge-icon svg {
  width: 24px;
  height: 24px;
}

.login-header h1 {
  font-size: 1.5rem;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ── APP LAYOUT ── */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: 72px;
  padding: 0 40px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(6, 6, 10, 0.6);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
  color: #06060a;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-icon svg {
  width: 18px;
  height: 18px;
}

.main-title {
  font-size: 1.15rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.sub-title {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.app-content {
  flex: 1;
  padding: 32px 40px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── METRICS GRID ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.metric-card {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric-val {
  font-size: 1.75rem;
  line-height: 1.1;
}

.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.metric-icon svg {
  width: 20px;
  height: 20px;
}

.color-blue {
  background: rgba(59, 130, 246, 0.08);
  color: var(--info-color);
}
.color-green {
  background: rgba(16, 185, 129, 0.08);
  color: var(--primary-color);
}
.color-amber {
  background: rgba(245, 158, 11, 0.08);
  color: var(--warning-color);
}
.color-red {
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger-color);
}

/* ── CONTROLS PANEL ── */
.controls-panel {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 450px;
}
.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}
.search-box input {
  padding-left: 44px;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.filter-controls select {
  min-width: 140px;
}

/* ── LICENSE TABLE ── */
.table-container {
  padding: 8px;
  overflow: hidden;
}

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

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

.license-table th, 
.license-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
}

.license-table th {
  font-weight: 500;
  color: var(--text-secondary);
  background-color: rgba(255, 255, 255, 0.01);
  text-transform: uppercase;
  font-size: 0.725rem;
  letter-spacing: 0.03em;
}

.license-table tr:last-child td {
  border-bottom: none;
}

.license-table tbody tr {
  transition: var(--transition);
}
.license-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.015);
}

.restaurant-name-cell {
  font-weight: 500;
  color: var(--text-primary);
}

.key-display {
  font-family: monospace;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.02);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-copy {
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}
.btn-copy:hover {
  color: var(--accent-color);
}
.btn-copy svg {
  width: 12px;
  height: 12px;
}

.expires-cell {
  color: var(--text-secondary);
}

.table-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-state-msg {
  text-align: center;
  padding: 40px !important;
  color: var(--text-secondary);
}

/* Spinner Loader */
.loader {
  border: 2px solid rgba(255, 255, 255, 0.05);
  border-top: 2px solid var(--accent-color);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Cards layout for small screens (hidden by default) */
.cards-responsive-list {
  display: none;
  flex-direction: column;
  gap: 16px;
  padding: 12px;
}

.responsive-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}
.responsive-card:last-child {
  border-bottom: none;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-title {
  font-weight: 600;
  font-size: 1rem;
}

.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.card-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 120px;
}
.card-info-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.card-info-val {
  font-size: 0.8rem;
}

.card-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* ── MODALS ── */
.modal-content {
  width: 100%;
  max-width: 550px;
  padding: 24px;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.modal-backdrop.active .modal-content {
  transform: scale(1);
  opacity: 1;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.col-12 { grid-column: span 12; }
.col-6 { grid-column: span 6; }

.modal-footer {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.max-sm {
  max-width: 440px;
}

/* Danger Modal customization */
.border-danger {
  border-color: rgba(239, 68, 68, 0.3) !important;
}
.danger-header {
  gap: 12px;
  justify-content: flex-start !important;
}
.text-danger {
  color: var(--danger-color);
}
.danger-icon {
  color: var(--danger-color);
  display: flex;
  align-items: center;
}
.danger-icon svg {
  width: 24px;
  height: 24px;
}
.danger-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.875rem;
}
.danger-alert {
  background: rgba(239, 68, 68, 0.08);
  border-left: 3px solid var(--danger-color);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #fca5a5;
}

/* ── TOAST NOTIFICATIONS ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: rgba(13, 13, 22, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  color: var(--text-primary);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 250px;
  max-width: 400px;
  transform: translateX(100px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s;
  pointer-events: auto;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.toast-success svg { color: var(--primary-color); }
.toast-error svg { color: var(--danger-color); }
.toast-warning svg { color: var(--warning-color); }

/* ── RESPONSIVE DESIGN (PHONE OPTIMIZATIONS) ── */
@media (max-width: 1024px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .app-header {
    padding: 0 24px;
  }
  
  .app-content {
    padding: 24px;
  }
}

@media (max-width: 767px) {
  body {
    font-size: 14px;
  }
  
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  
  .metric-card {
    padding: 16px 20px;
  }
  
  .controls-panel {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px;
  }
  
  .search-box {
    max-width: 100%;
  }
  
  .filter-controls {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .filter-controls select {
    flex: 1;
    min-width: 40%;
  }
  
  #btn-add-license {
    width: 100%;
    order: 3;
    margin-top: 4px;
  }
  
  /* Replace table layout with responsive card layout */
  .table-responsive-wrapper {
    display: none;
  }
  
  .cards-responsive-list {
    display: flex;
  }
  
  .table-container {
    padding: 0;
  }
  
  .col-6 {
    grid-column: span 12;
  }
  
  .login-card {
    padding: 24px;
    margin: 16px;
  }
  
  .app-header {
    height: 64px;
    padding: 0 16px;
  }
  
  .app-content {
    padding: 16px;
    gap: 16px;
  }
}
