/* ========================================
   AL-MANARA — Premium Design System
   ======================================== */

/* === ROOT VARIABLES === */
:root {
  --gold: #DAA520;
  --bright-gold: #FFD700;
  --soft-gold: #DAA520;
  --dark: #1A1A1A;
  --card: #242424;
  --card-hover: #2a2a2a;
  --border: rgba(218, 165, 32, 0.15);
  --glow: rgba(218, 165, 32, 0.15);
  --glow-strong: rgba(218, 165, 32, 0.35);
  --text-primary: #f0f0f0;
  --text-secondary: #999;
  --text-muted: #666;
  --radius: 16px;
  --radius-sm: 10px;

  /* Complementary accent palette */
  --teal: #40C0BF;
  --teal-dim: rgba(64, 192, 191, 0.12);
  --blue: #60A5FA;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --emerald: #34D399;
  --emerald-dim: rgba(52, 211, 153, 0.12);
  --rose: #FB7185;
  --rose-dim: rgba(251, 113, 133, 0.12);
  --purple: #A78BFA;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --amber: #FBBF24;
  --amber-dim: rgba(251, 191, 36, 0.12);
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--dark); }
::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bright-gold); }

/* === KEYFRAMES === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 15px rgba(201,168,76,0.1); }
  50% { box-shadow: 0 0 30px rgba(255,215,0,0.25); }
}
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes borderGlow {
  0%, 100% { border-color: rgba(201,168,76,0.2); }
  50% { border-color: rgba(255,215,0,0.5); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes particleFade {
  0% { opacity: 1; transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(0) translateY(-30px); }
}
@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* === BODY === */
body {
  background: var(--dark);
  background-image:
    radial-gradient(ellipse at 15% 60%, rgba(64,192,191,0.025) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 25%, rgba(218,165,32,0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(96,165,250,0.015) 0%, transparent 40%);
  min-height: 100vh;
}

/* === HERO === */
#hero-animation {
  background: radial-gradient(ellipse at center, #111 0%, #0a0a0a 70%);
}
#hero-text {
  transition: opacity 0.8s ease;
}

/* === PARTICLES === */
.particle {
  position: absolute;
  background: var(--bright-gold);
  border-radius: 50%;
  pointer-events: none;
  animation: particleFade 1s ease-out forwards;
  box-shadow: 0 0 8px var(--bright-gold), 0 0 20px var(--gold);
  z-index: 60;
}

/* === HEADER === */
.app-header {
  animation: fadeInUp 0.8s ease-out;
}
.app-header h1 {
  background: linear-gradient(135deg, var(--gold), var(--bright-gold), var(--gold));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 4s linear infinite;
}

/* === UPLOAD ZONE === */
.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(17,17,17,0.9), rgba(10,10,10,0.95));
  backdrop-filter: blur(10px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  cursor: pointer;
}
.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(201,168,76,0.06), transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.upload-zone:hover::before { opacity: 1; }
.upload-zone:hover {
  border-color: var(--gold);
  box-shadow: 0 0 40px rgba(201,168,76,0.1), inset 0 0 40px rgba(201,168,76,0.03);
  transform: translateY(-2px);
}
.upload-zone.drag-active {
  border-color: var(--bright-gold) !important;
  box-shadow: 0 0 60px rgba(255,215,0,0.2), inset 0 0 60px rgba(255,215,0,0.05) !important;
  transform: scale(1.01);
}
.upload-icon {
  filter: drop-shadow(0 0 12px rgba(201,168,76,0.5));
  transition: all 0.3s ease;
}
.upload-zone:hover .upload-icon {
  transform: translateY(-4px) scale(1.05);
  filter: drop-shadow(0 0 20px rgba(255,215,0,0.7));
}
.path-hint {
  background: rgba(201,168,76,0.08);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: 8px;
  padding: 8px 16px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.75rem;
  color: var(--gold);
  display: inline-block;
  margin-top: 12px;
  word-break: break-all;
}

/* === SPINNER === */
.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(201,168,76,0.2);
  border-top-color: var(--bright-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

/* === STAT CARDS === */
.stat-card {
  background: linear-gradient(145deg, rgba(26,26,26,0.8), rgba(17,17,17,0.9));
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeInUp 0.6s ease-out both;
}
.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

/* Per-card accent stripe at top */
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0.8;
  transition: opacity 0.3s;
}
.stat-card:nth-child(1)::after { background: linear-gradient(90deg, var(--gold), var(--bright-gold)); }
.stat-card:nth-child(2)::after { background: linear-gradient(90deg, var(--teal), #5EEAD4); }
.stat-card:nth-child(3)::after { background: linear-gradient(90deg, var(--blue), #93C5FD); }
.stat-card:nth-child(4)::after { background: linear-gradient(90deg, var(--emerald), #6EE7B7); }
.stat-card:hover::after { opacity: 1; }

.stat-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  transition: all 0.4s ease;
}
.stat-card:nth-child(1)::before { background: radial-gradient(circle, rgba(201,168,76,0.08), transparent 70%); }
.stat-card:nth-child(2)::before { background: radial-gradient(circle, var(--teal-dim), transparent 70%); }
.stat-card:nth-child(3)::before { background: radial-gradient(circle, var(--blue-dim), transparent 70%); }
.stat-card:nth-child(4)::before { background: radial-gradient(circle, var(--emerald-dim), transparent 70%); }

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 20px rgba(201,168,76,0.1);
}
.stat-card:nth-child(1):hover { border-color: rgba(201,168,76,0.4); }
.stat-card:nth-child(2):hover { border-color: rgba(45,212,191,0.4); }
.stat-card:nth-child(3):hover { border-color: rgba(96,165,250,0.4); }
.stat-card:nth-child(4):hover { border-color: rgba(52,211,153,0.4); }

.stat-card:hover::before {
  transform: scale(1.8);
}
.stat-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}
.stat-card:nth-child(2) .stat-icon { animation-delay: 0.5s; }
.stat-card:nth-child(3) .stat-icon { animation-delay: 1s; }
.stat-card:nth-child(4) .stat-icon { animation-delay: 1.5s; }

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.1;
}
/* Per-card value colors */
.stat-card:nth-child(1) .stat-value { color: var(--bright-gold); text-shadow: 0 0 20px rgba(255,215,0,0.3); }
.stat-card:nth-child(2) .stat-value { color: var(--teal); text-shadow: 0 0 20px rgba(45,212,191,0.25); }
.stat-card:nth-child(3) .stat-value { color: var(--blue); text-shadow: 0 0 20px rgba(96,165,250,0.25); }
.stat-card:nth-child(4) .stat-value { color: var(--emerald); text-shadow: 0 0 20px rgba(52,211,153,0.25); }

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* === CHART CARDS === */
.chart-card {
  background: linear-gradient(145deg, rgba(21,21,21,0.9), rgba(10,10,10,0.95));
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.3s ease;
  animation: fadeInUp 0.6s ease-out both;
}
.chart-card:hover {
  border-color: rgba(201,168,76,0.35);
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}
.chart-card h3 {
  font-family: 'Playfair Display', serif;
  color: var(--text-primary);
  font-size: 1.1rem;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(201,168,76,0.1);
}

/* === TABLE === */
.table-section {
  background: linear-gradient(145deg, rgba(21,21,21,0.9), rgba(10,10,10,0.95));
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeInUp 0.8s ease-out both;
  animation-delay: 0.3s;
}
.table-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(201,168,76,0.1);
}
.table-header h3 {
  font-family: 'Playfair Display', serif;
  color: var(--text-primary);
  font-size: 1.1rem;
}
.table-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.table-controls input,
.table-controls select {
  background: rgba(34,34,34,0.8);
  border: 1px solid rgba(201,168,76,0.2);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.85rem;
  transition: all 0.3s ease;
  outline: none;
}
.table-controls input:focus,
.table-controls select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(201,168,76,0.15);
}
.table-controls select option {
  background: #1a1a1a;
  color: #fff;
}

.table-wrapper {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
thead {
  position: sticky;
  top: 0;
  z-index: 10;
}
thead th {
  background: rgba(8,8,8,0.95);
  color: var(--gold);
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s;
  border-bottom: 2px solid rgba(201,168,76,0.15);
  user-select: none;
}
thead th:hover { color: var(--bright-gold); }
thead th.sorted-asc::after { content: ' ↑'; color: var(--bright-gold); }
thead th.sorted-desc::after { content: ' ↓'; color: var(--bright-gold); }

tbody tr {
  border-bottom: 1px solid rgba(201,168,76,0.05);
  transition: all 0.25s ease;
  animation: fadeIn 0.4s ease both;
}
tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.01);
}
tbody tr:hover {
  background: rgba(201,168,76,0.06);
  transform: scale(1.002);
}
tbody td {
  padding: 10px 16px;
  color: var(--text-secondary);
  vertical-align: middle;
}
tbody td:first-child {
  font-family: 'Consolas', monospace;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.patient-name { color: #fff !important; font-weight: 500; }
.shade-badge {
  display: inline-block;
  background: rgba(201,168,76,0.15);
  color: var(--gold);
  border: 1px solid rgba(201,168,76,0.3);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s;
}
.shade-badge:hover {
  background: rgba(201,168,76,0.25);
  transform: scale(1.08);
}
.unit-count {
  color: var(--teal) !important;
  font-weight: 700;
  font-size: 1rem;
}
.work-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.7rem;
  margin: 1px 2px;
  white-space: nowrap;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.work-tag:hover { transform: translateY(-1px); }
/* Color-coded work tags */
.work-tag--coping     { background: var(--teal-dim); color: var(--teal); border-color: rgba(45,212,191,0.2); }
.work-tag--crown      { background: var(--blue-dim); color: var(--blue); border-color: rgba(96,165,250,0.2); }
.work-tag--pontic     { background: var(--purple-dim); color: var(--purple); border-color: rgba(167,139,250,0.2); }
.work-tag--default    { background: rgba(201,168,76,0.08); color: var(--text-secondary); border-color: rgba(201,168,76,0.1); }
/* Material tags */
.mat-tag--zi          { background: var(--blue-dim); color: var(--blue); border-color: rgba(96,165,250,0.2); }
.mat-tag--pmma        { background: var(--emerald-dim); color: var(--emerald); border-color: rgba(52,211,153,0.2); }
.mat-tag--default     { background: rgba(251,191,36,0.08); color: var(--amber); border-color: rgba(251,191,36,0.15); }

.teeth-list {
  font-family: 'Consolas', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  opacity: 0.3;
}
.empty-state p { font-size: 0.95rem; }

/* === TOAST NOTIFICATION === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: linear-gradient(135deg, #1a1a1a, #111);
  border: 1px solid var(--border);
  border-left: 4px solid var(--emerald);
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 100;
  animation: fadeInUp 0.4s ease-out;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.toast-exit {
  animation: fadeOut 0.3s ease-in forwards;
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateY(10px); }
}

/* === EXPORT BUTTON === */
.export-btn:not(.hidden) { display: flex; }
.export-btn {
  background: linear-gradient(135deg, var(--gold), var(--bright-gold));
  color: var(--dark);
  font-weight: 700;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 15px rgba(201,168,76,0.2);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.export-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(255,215,0,0.4);
}
.export-btn:active { transform: translateY(0); }

/* Invoice Button in Table */
.invoice-btn {
  background: rgba(45, 212, 191, 0.1);
  border: 1px solid rgba(45, 212, 191, 0.2);
  color: var(--teal);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.invoice-btn:hover {
  background: var(--teal);
  color: #0a0a0a;
  border-color: var(--teal);
  box-shadow: 0 2px 8px rgba(45, 212, 191, 0.3);
}

.action-cell {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
}

/* === PAGINATION === */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid rgba(201,168,76,0.1);
  gap: 16px;
  flex-wrap: wrap;
}
.pagination-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}
.page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(26,26,26,0.8);
  border: 1px solid rgba(201,168,76,0.15);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
  font-weight: 500;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--bright-gold);
  background: rgba(201,168,76,0.08);
  transform: translateY(-1px);
}
.page-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.page-btn.active {
  background: linear-gradient(135deg, var(--gold), var(--bright-gold));
  color: var(--dark);
  border-color: var(--bright-gold);
  font-weight: 700;
  box-shadow: 0 0 12px rgba(201,168,76,0.3);
}
.page-numbers {
  display: flex;
  align-items: center;
  gap: 4px;
}
.page-ellipsis {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0 4px;
}
.pagination-size {
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-size-select {
  background: rgba(26,26,26,0.8);
  border: 1px solid rgba(201,168,76,0.2);
  color: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
}
.page-size-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(201,168,76,0.15);
}
.page-size-select option {
  background: #1a1a1a;
  color: #fff;
}

/* === PRICE MODAL === */
.price-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(201,168,76,0.06);
  transition: background 0.2s;
}
.price-row:hover {
  background: rgba(201,168,76,0.03);
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 8px;
}
.price-row:last-child {
  border-bottom: none;
}
.price-row-label {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
}
.price-row-input {
  width: 120px;
  background: rgba(26,26,26,0.8);
  border: 1px solid rgba(201,168,76,0.2);
  color: var(--bright-gold);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: right;
  outline: none;
  transition: all 0.2s;
}
.price-row-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(201,168,76,0.2);
}
.price-row-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}
.price-currency {
  color: var(--gold);
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 24px;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .stat-value { font-size: 2rem; }
  .stat-card { padding: 16px; }
  thead th, tbody td { padding: 8px 10px; }
  .table-controls { width: 100%; }
  .table-controls input,
  .table-controls select { width: 100%; }
  .hide-mobile { display: none !important; }
  .chart-card { padding: 16px; }
  .table-header { padding: 16px; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
  .pagination-bar { flex-direction: column; padding: 12px 16px; }
  .pagination-info { order: -1; width: 100%; text-align: center; }
  .pagination-size { width: 100%; justify-content: center; }
  .page-btn { width: 32px; height: 32px; font-size: 0.75rem; }
}

@media (max-width: 480px) {
  .stat-value { font-size: 1.6rem; }
  .stat-label { font-size: 0.65rem; letter-spacing: 1px; }
  table { font-size: 0.75rem; }
  .path-hint { font-size: 0.65rem; padding: 6px 10px; }
  .export-btn { width: 100%; text-align: center; }
  .app-header h1 { font-size: 1.5rem; }
}
