:root {
  --accent: #6c1d45;
  --accent-light: #9c2c5e;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(135deg, #fff4f7, #f6f0ff);
  margin: 0;
  padding: 16px;
  display: flex;
  justify-content: center;
  height: 100vh;
  overflow: hidden; /* Prevent scrolling */
  box-sizing: border-box;
}

.card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  max-width: 420px;
  width: 100%;
  padding: 12px 12px 6px 12px; 
  border: 1px solid rgba(255,255,255,0.3);
  overflow-y: auto;
}

.top-label {
  position: relative;
  text-align: center;
  margin-bottom: 8px;
}
.logo-box {
  display: inline-block;
  padding: 8px;
  border-radius: 14px;
  background: linear-gradient(135deg,#fbe9f0,#f3e7f9);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transition: all 0.6s ease;
}
.logo-box img {
  max-width: 80px;
  border-radius: 10px;
  display: block;
}

h1 {
  text-align: center;
  font-size: 1.2em;
  margin: 0 0 14px 0;
  color: var(--accent);
  font-weight: 700;
}

.micro-group {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.05);
  margin-bottom: 4px;
}

/* Reduce bottom margin for the measurement type group */
.micro-group.measurement-row {
  margin-bottom: 4px; /* Match the beverage card spacing */
}

/* Tighten the last micro-group */
.micro-group:last-of-type {
  margin-bottom: 8px; /* Reduced bottom margin for last group */
}

.micro-title {
  font-size: 0.75em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
  margin-top: 0px;
  margin-bottom: 4px; /* Consistent space below all titles */
}

.micro-group:last-of-type {
  margin-bottom: 6px; /* Keep consistent with others */
}

/* Specifically target the button rows to ensure consistent bottom spacing */
.btn-row:last-child {
  margin-bottom: 0;
}

/* Ensure inputs and buttons have consistent spacing */
input, select, textarea, button {
  margin-top: 6px;
  margin-bottom: 0;
}

/* Fix button fonts */
.btn-row button, 
#calcBtn, 
#clearBtn, 
#saveBtn {
    font-family: Arial, sans-serif !important; /* or whatever your button font was */
    font-size: 14px !important;
    font-weight: bold !important;
}

/* Also fix any other buttons that might be affected */
button {
    font-family: Arial, sans-serif !important;
    font-size: 14px !important;
}

.row {
  display: flex;
  gap: 10px;
  margin: 0;
}
.row label { flex: 1; }

label {
  display: block;
  margin-top: 6px;
  margin-bottom: 0px;
  font-weight: 600;
  font-size: 0.85em;
  color: #333;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid #e1e5e9;
  font-size: 0.95em;
  background: #fff;
  box-sizing: border-box;
  transition: all 0.2s ease;
  margin: 3px 0;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,29,69,0.1);
  outline: none;
}

button {
  margin-top: 6px;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108,29,69,0.3);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.btn-row button { flex: 1; }

/* Results */
.results {
  background: rgba(248, 249, 250, 0.8);
  border-radius: 12px;
  padding: 16px;
  border-left: 3px solid var(--accent);
}

.result-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-item {
  flex: 1 1 calc(50% - 8px);
  min-width: 120px;
  display: flex;
  align-items: center;
  font-size: 0.85em;
  margin-bottom: 4px;
}

.result-item b {
  color: var(--accent);
  margin-right: 4px;
}

.icon { 
  width: 20px; 
  margin-right: 6px; 
  text-align: center;
  font-size: 0.9em;
}

.progress-bar {
  flex: 1 1 100%;
  height: 12px;
  background: #e9ecef;
  border-radius: 6px;
  overflow: hidden;
  margin: 6px 0;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

#progressFill {
  height: 100%;
  width: 0;
  transition: all 0.6s ease;
}

/* Batch Actions */
/*.batch-actions {
  margin-top: 0px;
  padding-top: 10px;
  border-top: 0px solid rgba(0,0,0,0.1);
  padding-bottom: 0;
  margin-bottom: 0 !important; /* Force no bottom margin */
}

/* Batch Management specific fixes */
.batch-actions.micro-group {
  margin-bottom: 6px !important;
}

/* Compact the button rows in batch management */
 .batch-actions .btn-row {
  margin-bottom: 6px; /* Reduced spacing between button rows */
}


 .batch-actions .btn-row:last-child {
  margin-bottom: 0; /* Even less for the last row */
}

/* Ensure no extra space after the last elements */
/* .batch-actions > *:last-child {
  margin-bottom: 0;
}

.batch-actions .micro-title {
  margin-bottom: 6px !important;
} */

.batch-notes, .data-field, input, textarea, select {
    font-family: inherit;
    font-size: 14px; /* or whatever your original size was */
}

/* Ensure measurement row has same structure */
.measurement-row .micro-title {
  margin-bottom: 6px; /* Same as other titles */
}

#authSection {
  background: rgba(255,255,255,0.9);
  border-radius: 10px;
  padding: 12px;
  margin: 8px 0;
  border: 1px solid rgba(0,0,0,0.08);
}

/* Reduce spacing in cloud management sections */
#authSection, #cloudManagementSection {
  padding: 10px; /* Tighter padding */
  margin: 6px 0; /* Reduced margins */
}



/* Toast */
#toast {
  visibility: hidden;
  min-width: 220px;
  margin-left: -110px;
  color: #fff;
  text-align: center;
  border-radius: 12px;
  padding: 10px 16px;
  position: fixed;
  z-index: 10000;
  left: 50%;
  bottom: 24px;
  font-size: 0.85em;
  font-weight: 500;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s, transform 0.4s;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

#toast.show {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.toast-success { background: linear-gradient(135deg,#2ecc71,#27ae60); }
.toast-warning { background: linear-gradient(135deg,#f39c12,#f1c40f); color: #222; }
.toast-error { background: linear-gradient(135deg,#e74c3c,#c0392b); }
.toast-info { background: linear-gradient(135deg, #3498db, #2980b9); }

/* Help System */
.help-fab {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f6c343, #e8b438);
  color: #222;
  border: none;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 1001;
}

.help-panel {
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  max-height: 80%;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.2);
  padding: 24px;
  z-index: 100;
  display: none;
  overflow-y: auto;
}

#helpContentBox {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 20px;
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.help-header h2 {
  margin: 0;
  font-size: 1.2em;
  color: var(--accent);
}

.close {
  font-size: 22px;
  cursor: pointer;
  color: #666;
}

.help-section-title {
  font-weight: 600;
  margin: 12px 0 6px 0;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.9em;
  padding: 8px 12px;
  background: rgba(108, 29, 69, 0.05);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.help-section-title:hover {
  background: rgba(108, 29, 69, 0.1);
}

.help-section-content {
  display: none;
  margin-left: 12px;
  margin-bottom: 12px;
  color: #444;
  font-size: 0.85em;
  line-height: 1.4;
  padding: 8px 12px;
  background: rgba(248, 249, 250, 0.8);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.help-close-bottom {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  position: sticky;
  flex-shrink: 0;
}

/* Batch Management Enhancements */
.batch-management-header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--accent);
}

.batch-stats {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.stat-item {
  background: rgba(108, 29, 69, 0.1);
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 0.8em;
  font-weight: 600;
}

.batch-list-container {
  margin: 15px 0;
}

.batch-list-container label {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  display: block;
}

#batchList {
  width: 100%;
  padding: 10px;
  border: 1.5px solid #e1e5e9;
  border-radius: 10px;
  background: white;
  font-size: 0.9em;
  margin: 8px 0;
  display: block;
}

#batchList option {
  padding: 8px;
  border-bottom: 1px solid #f0f0f0;
}

#batchList option:hover {
  background: #f8f9fa;
}

#batchList option:checked {
  background: var(--accent);
  color: white;
}

/* Smart defaults visual indicators */
select.wine-default {
  border-left: 4px solid #8b0000;
  background: linear-gradient(90deg, rgba(139,0,0,0.05) 0%, transparent 100%);
}

select.cider-default {
  border-left: 4px solid #8fbc8f;
  background: linear-gradient(90deg, rgba(143,188,143,0.05) 0%, transparent 100%);
}

select.mead-default {
  border-left: 4px solid #daa520;
  background: linear-gradient(90deg, rgba(218,165,32,0.05) 0%, transparent 100%);
}

/* Cloud/Local batch indicators */
.cloud-batch { 
  border-left: 4px solid #3498db;
  background: linear-gradient(90deg, rgba(52,152,219,0.05) 0%, transparent 100%);
}

.local-batch { 
  border-left: 4px solid #27ae60;
  background: linear-gradient(90deg, rgba(39,174,96,0.05) 0%, transparent 100%);
}

/* Button variants */
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-light)) !important; }
.btn-secondary { background: linear-gradient(135deg, #6c757d, #5a6268) !important; }
.btn-success { background: linear-gradient(135deg, #28a745, #20c997) !important; }
.btn-danger { background: linear-gradient(135deg, #e74c3c, #c0392b) !important; }
.btn-warning { background: linear-gradient(135deg, #f39c12, #e67e22) !important; }
.btn-info { background: linear-gradient(135deg, #3498db, #2980b9) !important; }



#cloudManagementSection {
  position: relative !important; /* Force it to stay inside card */
  max-height: none !important;
  overflow-y: auto; /* Scroll if too tall */
}

.batch-management-header,
.batch-list-container,
.batch-actions-enhanced {
  position: relative !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close {
    color: #aaa;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal-body label {
    display: block;
    margin-bottom: 10px;
}

.modal-body input {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.forgot-password {
    text-align: center;
    margin-top: 10px;
}

.forgot-password a {
    color: #666;
    text-decoration: none;
    font-size: 0.9em;
}

.forgot-password a:hover {
    text-decoration: underline;
}

/* PWA-specific styles */
@media all and (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  /* Optional: Add some extra padding for iOS notch */
  .card {
    margin-top: 10px;
  }
}

/* Ensure proper fullscreen appearance */
html {
  height: 100%;
  background-color: #2c5530;
}

body {
  min-height: 100vh;
  background-color: #2c5530;
}

.install-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
}

.install-button {
  padding: 12px 20px;
  background: linear-gradient(135deg, #2c5530, #4a7c59);
  color: white;
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
  width: auto;
  white-space: nowrap;
}

.close-install-btn {
  padding: 8px;
  background: #666;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  width: 32px;
  height: 32px;
}

.close-install-btn:hover {
  background: #888;
}

.export-btn:hover {
    background: #8e44ad;
}

.export-csv-btn {
    background: #9b59b6;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
}

.export-csv-btn:hover {
    background: #8e44ad;
}