/* css/styles.css */

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

body {
  font-family: sans-serif;
  background: #f5f5f5;
  color: #222;
  padding: 1rem;
  line-height: 1.5;
}

header, main {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Header Styles */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  width: 100%;
}

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

#darkmode-toggle, #gear-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

/* Settings Menu Styles */
#settings-menu {
  position: absolute;
  top: 60px;
  right: 10px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 1rem;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  min-width: 250px;
}

#settings-menu.hidden {
  display: none;
}

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

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#close-settings {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* Toolbar Styles */
.toolbar {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  width: 100%;
}

.toolbar button {
  white-space: nowrap;
  padding: 0.5rem 1rem;
}

/* Form Elements */
button, input[type="text"], input[type="range"], select {
  padding: 0.5rem;
  font-size: 1rem;
  margin: 0;
}

label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input[type="text"] {
  width: 100%;
  max-width: 300px;
}

/* Table Styles */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th, td {
  padding: 0.5rem;
  border: 1px solid #ccc;
  text-align: left;
}

/* Dialog Styles */
.dialog-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2001;
}

.dialog-modal .dialog-content {
  position: relative;
  background: #222;
  padding: 1.5rem;
  border-radius: 0.5rem;
  min-width: 280px;
  max-width: 90vw;
  z-index: 2002;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.dialog-modal .dialog-content p {
  margin: 0 0 1rem 0;
  text-align: center;
  font-size: 1.1rem;
}

.dialog-modal .dialog-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: center;
}

.dialog-modal .dialog-buttons button {
  padding: 0.5rem;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  background: #333;
  color: white;
  transition: all 0.2s ease;
  min-width: 44px;
  min-height: 44px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.dialog-modal .dialog-buttons button:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

.dialog-modal .dialog-buttons button[value="increment"],
.dialog-modal .dialog-buttons button[value="decrement"] {
  font-size: 1.5rem;
  font-weight: bold;
  background: #2196f3;
  min-width: 44px;
  flex: 0.8;
  padding: 0;
}

.dialog-modal .dialog-buttons button[value="reset"] {
  background-color: #ffeb3b;
  color: black;
  font-size: 0.9rem;
  flex: 1;
  padding: 0.25rem;
}

.dialog-modal .dialog-buttons button[value="save"] {
  background-color: #4caf50;
  flex: 1;
  font-size: 0.9rem;
  padding: 0.25rem;
}

.dialog-modal .dialog-buttons button[value="cancel"] {
  background-color: #f44336;
  font-size: 0.9rem;
  flex: 1;
  padding: 0.25rem;
}

.dialog-modal .dialog-content input[type="number"] {
  width: 100%;
  padding: 0.75rem;
  font-size: 1.5rem;
  text-align: center;
  margin: 0.5rem 0;
  border: 1px solid #666;
  border-radius: 0.25rem;
  background: #333;
  color: white;
  -moz-appearance: textfield;
}

.dialog-modal .dialog-content input[type="number"]::-webkit-outer-spin-button,
.dialog-modal .dialog-content input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Dark Mode Styles */
body.dark {
  background: #111;
  color: #eee;
}

body.dark #settings-menu {
  background: #222;
  border-color: #444;
}

body.dark input,
body.dark button,
body.dark select {
  background: #222;
  color: #eee;
  border: 1px solid #444;
}

/* Responsive Styles */
@media (max-width: 480px) {
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  
  #settings-menu {
    top: 80px;
    right: 0;
    left: 0;
    margin: 0 1rem;
  }
  
  label {
    width: 100%;
  }
  
  select {
    flex: 1;
  }
}

/* Container specifically for camera & scanner mode selectors */
.camera-scanner-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

/* Original count dialog styling */
#count-dialog {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.75);
  z-index: 2000;
  visibility: visible;
  opacity: 1;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

#count-dialog.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

#count-dialog .dialog-content {
  position: relative;
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  width: 280px;
  max-width: 90%;
  margin: 1rem;
}

body.dark #count-dialog .dialog-content {
  background: #333;
  color: #fff;
}

/* Count input group styling */
.count-input-group {
  display: grid;
  grid-template-columns: 48px 48px 48px;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.5rem 0;
}

.count-input-group button {
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #ffffff;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.count-input-group button:hover {
  background: #f5f5f5;
  border-color: #999;
}

body.dark .count-input-group button {
  background: #555;
  color: #fff;
  border: 1px solid #666;
  box-shadow: none;
}

body.dark .count-input-group button:hover {
  background: #666;
  border-color: #777;
}

.input-wrapper {
  width: 48px;
  height: 48px;
  background: #ffffff;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #ccc;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

body.dark .input-wrapper {
  background: #333;
  border: 1px solid #666;
  box-shadow: none;
}

#count-dialog #count-input {
  width: 48px;
  height: 48px;
  min-width: 48px;
  max-width: 48px;
  border: none;
  background: #ffffff;
  color: #333;
  font-size: 1.25rem;
  text-align: center;
  padding: 0;
  margin: 0;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: none;
}

body.dark #count-dialog #count-input {
  background: #333;
  color: #fff;
}

/* Floating scanner button */
#fab-scan {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  z-index: 1100;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
}

#fab-scan:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

/* Scanner Modal Overlay */
#scanner-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

#scanner-overlay.active {
  display: flex;
}

#scanner-modal {
  background: #000;
  padding: 1rem;
  border-radius: 8px;
  position: relative;
  max-width: 90%;
  width: 640px;
}

#scanner-container {
  width: 640px;
  height: 360px;
  max-width: 100%;
  margin: 0 auto;
  background: #000;
  position: relative;
  overflow: hidden;
}

#close-scanner {
  position: absolute;
  top: 8px;
  right: 8px;
  background: red;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.5rem;
  cursor: pointer;
}

body.scanned {
  background: #4caf50 !important;
}

/* Custom Label Dialog Styles */
#label-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1200;
}

#label-dialog.hidden {
  display: none;
}

.dialog-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
}

.dialog-content {
  position: relative;
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  z-index: 1300;
  max-width: 90%;
  width: 320px;
}

body.dark .dialog-content {
  background: #222;
  color: #eee;
}

.dialog-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.dialog-buttons button {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #ffffff;
  color: #333;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.dialog-buttons button:hover {
  background: #f5f5f5;
  border-color: #999;
}

body.dark .dialog-buttons button {
  background: #555;
  color: #fff;
  border: 1px solid #666;
  box-shadow: none;
}

body.dark .dialog-buttons button:hover {
  background: #666;
  border-color: #777;
}

/* Ensure manual entry is not overlapped by the floating scanner button */
#manual-entry {
  margin-bottom: 100px;
}

/* Remove all old dialog styles */
#label-dialog,
#count-dialog,
.count-input-group,
.input-wrapper,
#count-dialog #count-input,
body.dark #count-dialog,
body.dark #count-dialog .dialog-content,
body.dark .count-input-group button,
body.dark .input-wrapper,
body.dark #count-dialog #count-input,
.dialog-content:not(.dialog-modal .dialog-content),
.dialog-buttons:not(.dialog-modal .dialog-buttons),
.dialog-overlay:not(.dialog-modal .dialog-overlay) {
  display: none !important;
}
