/* 
 * 58mm Thermal Receipt Generator & Simulator CSS
 * Modern Glassmorphic Dark UI + 48mm Thermal Paper Physics Simulator
 */

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

:root {
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --border-color: rgba(255, 255, 255, 0.1);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --warning: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --thermal-paper-bg: #faf9f6;
  --thermal-text: #111111;
  --thermal-width-58mm: 58mm;
  --thermal-printable-48mm: 48mm;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(to right, #f8fafc, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

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

/* Main Layout Grid */
.main-container {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 2rem;
  padding: 2rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* Glassmorphism Panel */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

input, select, textarea {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  color: #f8fafc;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

textarea {
  resize: vertical;
  min-height: 55px;
}

/* Line Items Editor */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 90px 36px;
  gap: 0.5rem;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

/* Tabs */
.tabs-header {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Simulator Canvas Workspace */
.simulator-workspace {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 2rem;
  overflow-y: auto;
  position: relative;
  min-height: 600px;
}

/* Thermal Paper Roll Simulation */
.thermal-paper-shadow {
  filter: drop-shadow(0 15px 25px rgba(0, 0, 0, 0.5));
}

.thermal-paper-roll {
  width: var(--thermal-width-58mm);
  background: var(--thermal-paper-bg);
  color: var(--thermal-text);
  padding: 5mm;
  box-sizing: border-box;
  position: relative;
  border-top: 3px dashed #cbd5e1;
  border-bottom: 3px dashed #cbd5e1;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.04);
}

/* 48mm Printable Area Container */
.printable-area {
  width: var(--thermal-printable-48mm);
  margin: 0 auto;
  background: transparent;
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 11.5px;
  line-height: 1.25;
  letter-spacing: 0px;
  color: #000;
  position: relative;
  user-select: text;
  box-sizing: content-box;
}

/* Line character display */
.receipt-line {
  white-space: pre;
  position: relative;
}

/* Warning for overflow */
.receipt-line.overflow-warning {
  background-color: rgba(239, 68, 68, 0.2);
  outline: 1px solid #ef4444;
}

/* 32 Character Column Grid Ruler Overlay */
.column-ruler {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: none;
  grid-template-columns: repeat(32, 1fr);
  opacity: 0.15;
}

.column-ruler.show {
  display: grid;
}

.column-ruler span {
  border-right: 1px dashed #ef4444;
  height: 100%;
}

.column-ruler span:last-child {
  border-right: 2px solid #ef4444; /* Column 32 warning boundary */
}

/* Code Output Area */
.code-block {
  background: #020617;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #38bdf8;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 450px;
}

/* Status Indicator Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.disconnected {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.connected {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Thermal Print Media Queries */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .app-header, .panel, .tabs-header, .simulator-controls, .column-ruler {
    display: none !important;
  }
  .main-container {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .simulator-workspace {
    background: #fff !important;
    border: none !important;
    padding: 0 !important;
  }
  .thermal-paper-shadow, .thermal-paper-roll {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    width: 58mm !important;
  }
  .printable-area {
    width: 48mm !important;
    margin: 0 !important;
    padding: 0 !important;
  }
}
