/* Font declarations */
@font-face {
  font-family: 'DotMatrix';
  src: url('../fonts/dotmatrix.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'DotMatrix';
  src: url('../fonts/dotmatrixbold.woff2') format('woff2');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.3;
  color: #333;
  background-color: #f0f0f0;
  padding: 0;
  margin: 0;
  font-size: 13px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Layout */
header {
  background-color: #333;
  color: white;
  padding: 0.3rem 0.75rem;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 1rem;
  margin-right: 1rem;
}

header p {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  align-items: center;
}

.mode-btn {
  background: transparent;
  color: #ccc;
  border: none;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 3px;
  margin: 0 0.2rem;
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mode-btn.active {
  color: white;
  font-weight: 500;
}

.mode-btn.mode-receipt.active {
  background: #2b6cb0;
}

.mode-btn.mode-image.active {
  background: #c53030;
}

/* Content modes */
.mode-content {
  display: none;
  flex: 1;
}

.mode-content.active {
  display: flex;
}

main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.panels {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Configuration panel */
.config-panel {
  flex: 1;
  min-width: 320px;
  max-width: 400px;
  background: white;
  padding: 0.5rem;
  border-right: 1px solid #ddd;
  overflow-y: auto;
}

/* Image config panel - Red theme */
.image-config-panel {
  border-right-color: #e53e3e;
}

.image-config-panel h2,
.image-config-panel h3 {
  color: #c53030;
}

.image-config-panel .btn-primary {
  background-color: #c53030;
  border-color: #c53030;
}

.image-config-panel .btn-primary:hover {
  background-color: #9b2c2c;
}

.config-section {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
}

.config-section:last-child {
  border-bottom: none;
}

h2 {
  color: #333;
  margin-bottom: 0.3rem;
  font-size: 1rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.2rem;
}

h3 {
  color: #555;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Form elements */
.input-group {
  margin-bottom: 0.3rem;
  width: 100%;
}

.input-group label {
  display: block;
  margin-bottom: 0.1rem;
  color: #555;
  font-size: 0.7rem;
  font-weight: 500;
}

.image-config-panel .input-group label {
  color: #742a2a;
}

.input-group input,
.input-group textarea,
.input-group select {
  width: 100%;
  padding: 0.2rem;
  border: 1px solid #ccc;
  font-size: 0.8rem;
  font-family: inherit;
  height: 1.6rem;
}

.image-config-panel .input-group input:focus,
.image-config-panel .input-group textarea:focus,
.image-config-panel .input-group select:focus {
  border-color: #c53030;
  outline: none;
}

.input-group input[type="range"] {
  height: 0.8rem;
}

.input-group input[type="file"] {
  padding: 0.1rem;
  height: auto;
}

.input-group input[type="checkbox"] {
  width: auto;
  height: auto;
  margin-right: 0.5rem;
}

.input-group textarea {
  height: auto;
  line-height: 1.2;
  resize: vertical;
  min-height: 2.5em;
  max-height: 5em;
}

.input-group-small {
  width: 30%;
  min-width: 80px;
}

.flex-row {
  display: flex;
  gap: 0.3rem;
  align-items: flex-start;
}

.read-only-field {
  padding: 0.2rem;
  border: 1px solid #ddd;
  background-color: #f5f5f5;
  min-height: 1.6rem;
  display: flex;
  align-items: center;
  font-size: 0.8rem;
}

/* Receipt preview panel */
.preview-panel {
  flex: 0;
  width: 300px;
  min-width: 300px;
  background: white;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #ddd;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.preview-header h2 {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
  font-size: 0.95rem;
}

/* Receipt & Image panels styling */
#receiptModeContent .preview-header h2 {
  color: #2b6cb0;
}

#imageModeContent .preview-header h2 {
  color: #c53030;
}

#imageModeContent .preview-panel {
  border-right-color: #e53e3e;
}

.preview-controls {
  display: flex;
  gap: 0.5rem;
}

.receipt-wrapper {
  background-color: #f0f0f0;
  padding: 0.5rem;
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.receipt-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  align-items: flex-start;
  justify-content: flex-start;
  display: flex;
}

.receipt {
  font-family: 'DotMatrix', monospace;
  background-color: white;
  padding: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.2;
  white-space: pre;
  width: 384px;
  border: 1px solid #ddd;
  height: auto;
  max-height: 100%;
  transform-origin: top left;
}

/* Image Preview Panel - Updated for consistency */
.image-wrapper {
  background-color: #fff;
  padding: 0.5rem;
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  border: 1px solid #e53e3e;
}

.image-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  align-items: center;
  justify-content: center;
  display: flex;
  position: relative;
  background-color: #fff;
  min-height: 200px;
  border: 2px dashed #e53e3e;
}

#imagePreview {
  max-width: 100%;
  max-height: 100%;
  display: none;
  image-rendering: pixelated;
}

#imagePreviewMessage {
  font-size: 0.8rem;
  color: #742a2a;
  text-align: center;
  padding: 1rem;
  font-weight: 500;
}

/* Drag and Drop styles - Updated for consistency */
#dropZone {
  position: relative;
  transition: all 0.3s ease;
}

#dropZone.drag-over {
  background-color: #fff5f5;
}

#dropZone.drag-over .image-container {
  border-color: #c53030;
  border-style: solid;
}

/* Printer log panel */
.log-panel {
  flex: 1;
  min-width: 200px;
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.log-panel h2 {
  color: #fff;
  padding-bottom: 0.3rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.log-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.log-controls button {
  background: #333;
  color: #eee;
  border: 1px solid #555;
  font-size: 0.7rem;
}

.log-wrapper {
  flex: 1;
  background: #252525;
  padding: 0.5rem;
  overflow: auto;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.8rem;
  border: 1px solid #333;
}

.log-entry {
  margin-bottom: 0.4rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px dotted #444;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-time {
  color: #888;
  font-size: 0.7rem;
}

.log-message {
  margin-top: 0.1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-info {
  color: #59b8ff;
}

.log-success {
  color: #4ec9b0;
}

.log-warn {
  color: #dcdcaa;
}

.log-error {
  color: #f14c4c;
}

.log-data {
  color: #b5cea8;
}

/* Progress bar */
.progress-container {
  width: 100%;
  background-color: #333;
  height: 6px;
  margin: 0.5rem 0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background-color: #4ec9b0;
  transition: width 0.3s;
}

/* Items list */
#itemsList {
  margin-bottom: 0.3rem;
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid #ddd;
  min-height: 40px;
  background-color: #fff;
  width: 100%;
}

#itemsList:empty {
  padding: 0.2rem;
  font-style: italic;
  font-size: 0.8rem;
  color: #999;
}

#itemsList:empty::before {
  content: 'No items added yet';
  display: block;
  padding: 10px;
  color: #888;
  font-style: italic;
  text-align: left;
  width: 100%;
}

.item-row {
  display: flex;
  align-items: center;
  padding: 0.2rem 0.3rem;
  border-bottom: 1px solid #eee;
  width: 100%;
}

.item-row:last-child {
  border-bottom: none;
}

.item-name {
  flex: 1;
}

.item-price {
  margin-right: 10px;
  font-weight: 500;
}

.item-delete {
  cursor: pointer;
  color: #c53030;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 5px;
}

.item-delete:hover {
  color: #9b2c2c;
}

/* Item entry styling */
.item-entry {
  border: 1px solid #ddd;
  padding: 0.3rem;
  background-color: #fafafa;
  margin-top: 0.3rem;
}

.item-entry .flex-row {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.item-entry .input-group {
  margin-bottom: 0;
}

#newItemName, #newItemPrice {
  height: 32px;
}

#addItemBtn {
  height: 32px;
  background-color: #2b6cb0;
  color: white;
  border-color: #2b6cb0;
  padding: 0.3rem 0.6rem;
}

/* Buttons - updated for consistency */
button {
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border: 1px solid #ccc;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: #f5f5f5;
  border-radius: 2px;
}

.btn-primary {
  background-color: #2b6cb0;
  color: white;
  border-color: #2b6cb0;
}

.btn-primary:hover {
  background-color: #1a4d8c;
}

.btn-secondary {
  background-color: #666;
  color: white;
  border-color: #666;
}

.btn-secondary:hover {
  background-color: #555;
}

/* Connect button and print button styles */
.connect-btn {
  margin-right: 8px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Action buttons container */
.action-buttons {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  gap: 8px;
}

.action-buttons button {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

/* Image mode specific button styling */
.image-config-panel .btn-primary {
  background-color: #c53030;
  border-color: #c53030;
}

.image-config-panel .btn-primary:hover {
  background-color: #9b2c2c;
}

/* Reset button consistent styling */
#resetBtn, #resetImageBtn {
  background-color: #666;
  color: white;
  border-color: #666;
}

#resetBtn:hover, #resetImageBtn:hover {
  background-color: #555;
}

/* Make all status indicators consistent */
.printing-status {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.3rem;
  color: white;
  text-align: center;
  transform: translateY(-100%);
  transition: transform 0.3s;
  z-index: 10;
  font-size: 0.8rem;
  font-weight: 500;
}

#receiptModeContent ~ .printing-status {
  background-color: #3182ce;
}

#imageModeContent ~ .printing-status {
  background-color: #c53030;
}

/* Footer */
footer {
  text-align: left;
  padding: 0.3rem 0.75rem;
  color: #777;
  font-size: 0.7rem;
  background-color: #f0f0f0;
  border-top: 1px solid #ddd;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

footer a {
  color: #2b6cb0;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Battery indicator styles */
.battery-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
}

.battery-icon {
  display: inline-block;
  font-size: 0.8rem;
  margin-right: 1px;
}

.battery-level {
  font-size: 0.7rem;
  font-weight: 500;
}

.battery-level.low {
  color: #c53030;
}

.battery-level.medium {
  color: #dd6b20;
}

.battery-level.high {
  color: #2f855a;
}

/* Printing status */
.printing-status {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.3rem;
  background-color: #3182ce;
  color: white;
  text-align: center;
  transform: translateY(-100%);
  transition: transform 0.3s;
  z-index: 10;
  font-size: 0.8rem;
}

.printing-status.active {
  transform: translateY(0);
}

.printing-status.error {
  background-color: #c53030;
}

.printing-status.success {
  background-color: #2f855a;
}

/* Receipt specifics */
.receipt-divider {
  border-bottom: 1px dashed black;
  height: 1px;
  margin: 6px 0;
}

.receipt-text-center {
  text-align: center;
}

.receipt-text-right {
  text-align: right;
}

.receipt-bold {
  font-weight: bold;
}

/* Item entry section */
.item-entry {
  border: 1px solid #ddd;
  padding: 0.3rem;
  background-color: #fafafa;
}

/* Receipt summary */
.receipt-summary {
  margin-top: 0.3rem;
  padding: 0.3rem;
  border: 1px solid #ddd;
  background-color: #f5f5f5;
  font-size: 0.7rem;
  width: 100%;
  box-sizing: border-box;
}

.summary-section {
  margin-bottom: 0.2rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  white-space: nowrap;
}

.summary-total {
  font-weight: bold;
}

/* File upload styling - updated for design consistency */
.file-upload-container {
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
}

.image-config-panel .file-upload-container {
  border-color: #e53e3e;
}

.file-upload-container input[type="file"] {
  height: auto;
  width: 100%;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-size: 0.8rem;
  color: #333;
}

/* Remove the default file input button */
.file-upload-container input[type="file"]::-webkit-file-upload-button {
  padding: 0.2rem 0.4rem;
  margin-right: 8px; 
  border: none;
  background: #f5f5f5;
  color: #333;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  border-right: 1px solid #ccc;
  height: 1.6rem;
}

.image-config-panel .file-upload-container input[type="file"]::-webkit-file-upload-button {
  background: #fff5f5;
  color: #c53030;
  border-right: 1px solid #e53e3e;
}

.file-upload-container input[type="file"]::-webkit-file-upload-button:hover {
  background: #e6e6e6;
}

.image-config-panel .file-upload-container input[type="file"]::-webkit-file-upload-button:hover {
  background: #fed7d7;
}

/* Rotation controls */
.rotation-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background-color: #fff;
  border: 1px solid #e53e3e;
  padding: 4px 8px;
}

.rotation-icon {
  font-size: 1.2rem;
  font-weight: bold;
}

#rotationDisplay {
  font-size: 0.9rem;
  font-weight: 500;
  color: #742a2a;
  flex-grow: 1;
  text-align: center;
}

.btn-icon {
  background: transparent;
  border: 1px solid #e53e3e;
  color: #c53030;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-icon:hover {
  background-color: #fff5f5;
}