/* ==========================================================================
   RECEIPT INTERCEPTOR - PREMIUM STYLING SYSTEM
   ========================================================================== */

:root {
  /* Elegant Color Palette */
  --bg-primary: #080c14;
  --bg-secondary: #0d1527;
  --card-bg: rgba(16, 26, 48, 0.5);
  --card-bg-hover: rgba(22, 37, 68, 0.65);
  --border-light: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(0, 240, 255, 0.15);
  
  /* Glowing Accent Colors */
  --color-cyan: #00f0ff;
  --color-cyan-glow: rgba(0, 240, 255, 0.4);
  --color-emerald: #00f59b;
  --color-emerald-glow: rgba(0, 245, 155, 0.3);
  --color-pink: #ff2a85;
  --color-pink-glow: rgba(255, 42, 133, 0.3);
  --color-purple: #9d4edd;
  
  /* Text Colors */
  --text-main: #f0f4fc;
  --text-muted: #8fa0c4;
  --text-dark: #4b5b7c;

  /* Font Families */
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Fira Code', 'Courier New', Courier, monospace;
}

/* Reset and Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-display);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0, 240, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(157, 78, 221, 0.05) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.3);
}

/* App Container Layout */
.app-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Header System --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 24px;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-glow {
  position: absolute;
  width: 40px;
  height: 40px;
  background: var(--color-cyan);
  filter: blur(20px);
  opacity: 0.5;
  border-radius: 50%;
  left: 0;
}

.logo-icon {
  width: 36px;
  height: 36px;
  color: var(--color-cyan);
  filter: drop-shadow(0 0 8px var(--color-cyan-glow));
  z-index: 1;
}

.brand-text h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
}

.brand-text h1 span {
  color: var(--color-cyan);
  text-shadow: 0 0 10px var(--color-cyan-glow);
}

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

/* Status Panel */
.status-panel {
  display: flex;
  gap: 12px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
}

.status-badge .indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-badge .indicator.pulsing {
  background-color: var(--color-cyan);
  box-shadow: 0 0 8px var(--color-cyan-glow);
  animation: pulse 1.8s infinite;
}

.status-badge .indicator.active {
  background-color: var(--color-emerald);
  box-shadow: 0 0 8px var(--color-emerald-glow);
}

.status-badge .indicator.error {
  background-color: var(--color-pink);
  box-shadow: 0 0 8px var(--color-pink-glow);
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px var(--color-cyan-glow); }
  100% { transform: scale(0.9); opacity: 0.5; }
}

/* --- Dashboard Core Layout --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
  flex: 1;
}

/* Glassmorphism Card System */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.glass-card:hover {
  border-color: rgba(0, 240, 255, 0.15);
  box-shadow: 0 12px 40px 0 rgba(0, 240, 255, 0.03);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  border-left: 3px solid var(--color-cyan);
  padding-left: 10px;
  letter-spacing: 0.5px;
}

/* --- Left Column Elements --- */
.left-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.config-card {
  flex-shrink: 0;
}

.config-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.config-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.15);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  font-size: 13.5px;
}

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

.config-value {
  font-family: var(--font-mono);
  font-weight: 500;
}

.config-value.highlight {
  color: var(--color-cyan);
}

.config-value.highlight-pink {
  color: var(--color-pink);
  font-size: 12px;
}

.config-tip {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--color-cyan) 0%, #00bcff 100%);
  color: #000;
  box-shadow: 0 4px 15px rgba(0, 240, 255, 0.2);
  font-weight: 600;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 240, 255, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Stats panel */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
}

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

.stat-icon-wrapper.success {
  background: rgba(0, 245, 155, 0.1);
  color: var(--color-emerald);
  border: 1px solid rgba(0, 245, 155, 0.2);
}

.stat-icon-wrapper.info {
  background: rgba(0, 240, 255, 0.1);
  color: var(--color-cyan);
  border: 1px solid rgba(0, 240, 255, 0.2);
}

.stat-icon-wrapper svg {
  width: 22px;
  height: 22px;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Terminal Real-time logs */
.terminal-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-color: var(--border-light);
  min-height: 240px;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-light);
}

.window-buttons {
  display: flex;
  gap: 6px;
}

.window-buttons span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.window-buttons span:nth-child(1) { background: #ff5f56; }
.window-buttons span:nth-child(2) { background: #ffbd2e; }
.window-buttons span:nth-child(3) { background: #27c93f; }

.terminal-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.btn-clear {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.terminal-body {
  flex: 1;
  background: rgba(3, 7, 18, 0.85);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-y: auto;
  line-height: 1.6;
  position: relative;
}

/* Scanline Overlay for terminal styling */
.terminal-body::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 4px, 6px 100%;
  z-index: 10;
  pointer-events: none;
  opacity: 0.4;
}

.log-line {
  margin-bottom: 8px;
  word-break: break-all;
  opacity: 0.85;
}

.log-line.system {
  color: #708090;
}

.log-line.info {
  color: #00bcff;
}

.log-line.success {
  color: var(--color-emerald);
  text-shadow: 0 0 4px rgba(0, 245, 155, 0.2);
}

.log-line.warning {
  color: #ffb703;
}

.log-line.error {
  color: var(--color-pink);
  text-shadow: 0 0 4px rgba(255, 42, 133, 0.2);
}

.log-time {
  color: var(--text-dark);
  margin-right: 8px;
  font-size: 11px;
}

/* --- Right Column Library Panel --- */
.right-panel {
  display: flex;
}

.library-card {
  width: 100%;
  display: flex;
  flex-direction: column;
}

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

.library-header .card-title {
  margin-bottom: 0;
}

/* Empty Library View */
.library-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  position: relative;
}

.empty-glow {
  position: absolute;
  width: 200px;
  height: 200px;
  background: var(--color-cyan);
  filter: blur(80px);
  opacity: 0.04;
  border-radius: 50%;
}

.empty-icon {
  width: 64px;
  height: 64px;
  color: var(--text-dark);
  margin-bottom: 20px;
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.3));
}

.library-empty h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.library-empty p {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.6;
}

.library-empty code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  color: var(--color-cyan);
  font-size: 12.5px;
}

/* Receipt Grid and Cards */
.receipt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 10px;
}

/* Beautiful Receipt Card */
.receipt-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.receipt-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-cyan), var(--color-purple));
  opacity: 0;
  transition: opacity 0.25s;
}

.receipt-card:hover {
  background: var(--card-bg-hover);
  transform: translateY(-4px);
  border-color: rgba(0, 240, 255, 0.25);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.receipt-card:hover::before {
  opacity: 1;
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.file-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(0, 240, 255, 0.06);
  color: var(--color-cyan);
  border: 1px solid rgba(0, 240, 255, 0.12);
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.file-icon-wrapper svg {
  width: 22px;
  height: 22px;
}

.file-meta-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.receipt-card-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.receipt-card-date {
  font-size: 12px;
  color: var(--text-muted);
}

.receipt-card-size {
  font-size: 11px;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  padding: 1px 6px;
  border-radius: 4px;
  align-self: flex-start;
  color: var(--text-muted);
}

.card-actions {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
}

.btn-card {
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-card-preview {
  background: rgba(0, 240, 255, 0.08);
  color: var(--color-cyan);
  border: 1px solid rgba(0, 240, 255, 0.15);
}

.btn-card-preview:hover {
  background: var(--color-cyan);
  color: #000;
  box-shadow: 0 0 12px var(--color-cyan-glow);
}

.btn-card-delete {
  background: rgba(255, 42, 133, 0.08);
  color: var(--color-pink);
  border: 1px solid rgba(255, 42, 133, 0.15);
}

.btn-card-delete:hover {
  background: var(--color-pink);
  color: #fff;
  box-shadow: 0 0 12px var(--color-pink-glow);
}

/* Card Entrance animation */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-entrance {
  animation: slideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Card Exit animation */
@keyframes slideOut {
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

.animate-exit {
  animation: slideOut 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --- Premium Modal Overlay System --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(4, 7, 14, 0.7);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  animation: fadeIn 0.25s ease-out;
}

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

.modal-container {
  background: rgba(13, 22, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
  max-width: 960px;
  height: 90vh;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: scaleUp 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.15);
}

@keyframes scaleUp {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-light);
}

.modal-title-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title-wrapper svg {
  width: 20px;
  height: 20px;
  color: var(--color-cyan);
}

.modal-title-wrapper h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  padding: 0 4px;
}

.modal-close:hover {
  color: var(--color-pink);
}

.modal-body {
  flex: 1;
  background: #0b0f19;
  position: relative;
  overflow: hidden;
}

/* JSON Viewer */
#json-viewer {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 20px 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: #a8d8a8;
  background: #0b0f19;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  box-sizing: border-box;
}

/* JSON syntax highlight (applied via JS) */
#json-viewer .json-key    { color: #79b8ff; }
#json-viewer .json-str    { color: #9ecbff; }
#json-viewer .json-num    { color: #f97583; }
#json-viewer .json-bool   { color: #ffab70; }
#json-viewer .json-null   { color: #959da5; }
/* receipt data string gets an accent color */
#json-viewer .json-receipt { color: var(--color-emerald); }

/* Responsive Scaling */
@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .app-container {
    padding: 16px;
  }
}
