/**
 * Stiluri pentru aplicatia de test cantar
 * Web Serial API - Cititor Cantar Professional
 */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* Container principal */
.container {
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 40px;
  max-width: 600px;
  width: 100%;
}

/* Header */
h1 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
  font-size: 28px;
}

.scale-icon {
  text-align: center;
  font-size: 48px;
  margin-bottom: 20px;
}

/* Indicator status conexiune */
.status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 600;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-dot.connected {
  background: #10b981;
}

.status-dot.disconnected {
  background: #ef4444;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Selector preset/locatie */
.preset-selector {
  background: #f0f9ff;
  border: 2px solid #0ea5e9;
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 20px;
}

.preset-selector label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #0369a1;
  margin-bottom: 8px;
}

.preset-selector select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #7dd3fc;
  font-size: 14px;
  background: white;
  cursor: pointer;
}

.preset-selector select:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.preset-description {
  font-size: 12px;
  color: #64748b;
  margin-top: 8px;
  font-style: italic;
}

/* Panou setari */
.settings-panel {
  background: #f9fafb;
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 20px;
  display: none;
}

.settings-panel.show {
  display: block;
}

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

.settings-header:not(:first-child) {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #e5e7eb;
}

.settings-header h3 {
  font-size: 14px;
  color: #374151;
}

.setting-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.setting-row label {
  width: 140px;
  font-size: 13px;
  color: #4b5563;
}

.setting-row select,
.setting-row input {
  flex: 1;
  padding: 8px;
  border-radius: 5px;
  border: 1px solid #d1d5db;
  font-size: 13px;
}

.setting-row select:focus,
.setting-row input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.setting-hint {
  font-size: 11px;
  color: #9ca3af;
  margin-left: 140px;
  margin-top: -5px;
  margin-bottom: 10px;
}

/* Butoane */
.toggle-settings {
  background: #6b7280;
  color: white;
  padding: 8px 16px;
  font-size: 14px;
  margin-bottom: 10px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.toggle-settings:hover {
  background: #4b5563;
}

.button-group {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
}

button {
  flex: 1;
  padding: 15px 30px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-connect {
  background: #10b981;
  color: white;
}

.btn-disconnect {
  background: #ef4444;
  color: white;
}

.btn-read {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  width: 100%;
  padding: 20px;
  font-size: 18px;
}

.btn-read.reading {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  animation: pulse 1s infinite;
}

.btn-read:disabled {
  background: #e5e7eb;
  color: #9ca3af;
}

/* Display greutate */
.weight-display {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 15px;
  padding: 30px;
  margin: 30px 0;
  text-align: center;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.weight-value {
  font-size: 48px;
  font-weight: bold;
  color: white;
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}

.weight-unit {
  font-size: 24px;
  color: rgba(255, 255, 255, 0.9);
}

.waiting-text {
  color: rgba(255, 255, 255, 0.8);
  font-size: 18px;
}

/* Info box */
.info-box {
  background: #f3f4f6;
  border-radius: 10px;
  padding: 15px;
  margin-top: 20px;
  font-size: 14px;
  color: #4b5563;
  display: none;
}

.info-box.show {
  display: block;
}

.info-box.success {
  background: #d1fae5;
  color: #065f46;
}

.info-box.error {
  background: #fee2e2;
  color: #991b1b;
}

/* Loading spinner */
.loading-spinner {
  display: none;
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

.loading-spinner.show {
  display: block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Ultimele citiri */
.last-readings {
  margin-top: 20px;
  padding: 15px;
  background: #f3f4f6;
  border-radius: 10px;
  display: none;
}

.last-readings.show {
  display: block;
}

.last-readings h3 {
  font-size: 16px;
  color: #4b5563;
  margin-bottom: 10px;
}

.reading-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #e5e7eb;
  font-size: 14px;
}

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

.reading-time {
  color: #6b7280;
}

.reading-value {
  font-weight: 600;
  color: #111827;
}

/* Debug info */
.debug-section {
  margin-top: 20px;
}

.debug-toggle {
  text-align: center;
}

.debug-toggle button {
  background: #6b7280;
  color: white;
  padding: 5px 15px;
  font-size: 12px;
}

.debug-info {
  margin-top: 10px;
  padding: 10px;
  background: #1f2937;
  color: #10b981;
  font-family: monospace;
  font-size: 12px;
  border-radius: 5px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.debug-info.show {
  display: block;
}

/* Raw data display */
.raw-data-display {
  margin-top: 10px;
  padding: 10px;
  background: #111827;
  color: #f59e0b;
  font-family: monospace;
  font-size: 11px;
  border-radius: 5px;
  max-height: 100px;
  overflow-y: auto;
  display: none;
  white-space: pre-wrap;
  word-break: break-all;
}

.raw-data-display.show {
  display: block;
}

/* Protocol info badge */
.protocol-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 10px;
}

.protocol-badge.lf {
  background: #dbeafe;
  color: #1d4ed8;
}

.protocol-badge.cr {
  background: #fef3c7;
  color: #b45309;
}

/* Debug Raw Button */
.btn-debug-raw {
  width: 100%;
  margin-top: 15px;
  padding: 15px 30px;
  font-size: 14px;
  font-weight: 600;
  background: #f59e0b;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-debug-raw:hover:not(:disabled) {
  background: #d97706;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.btn-debug-raw:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-debug-raw.reading {
  background: #dc2626;
  animation: pulse 1s infinite;
}

/* Raw Debug Output Area */
.raw-debug-output {
  margin-top: 20px;
  background: #1e293b;
  border-radius: 10px;
  overflow: hidden;
  display: none;
}

.raw-debug-output.show {
  display: block;
}

.raw-debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: #334155;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
}

.btn-clear-debug {
  padding: 5px 12px;
  font-size: 11px;
  background: #64748b;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  flex: none;
}

.btn-clear-debug:hover {
  background: #475569;
}

.raw-debug-content {
  padding: 15px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #f8fafc;
  max-height: 300px;
  overflow-y: auto;
}

.raw-debug-content .placeholder-text {
  color: #94a3b8;
  font-style: italic;
}

.raw-debug-content .debug-entry {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #475569;
}

.raw-debug-content .debug-entry:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.raw-debug-content .debug-label {
  color: #38bdf8;
  font-weight: bold;
  margin-bottom: 5px;
}

.raw-debug-content .debug-hex {
  color: #4ade80;
  word-break: break-all;
  line-height: 1.6;
}

.raw-debug-content .debug-raw {
  color: #fbbf24;
  word-break: break-all;
  white-space: pre-wrap;
}

.raw-debug-content .debug-info-line {
  color: #a78bfa;
  font-size: 11px;
  margin-top: 5px;
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 20px;
  }

  h1 {
    font-size: 22px;
  }

  .weight-value {
    font-size: 36px;
  }

  .button-group {
    flex-direction: column;
  }

  .setting-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .setting-row label {
    width: 100%;
    margin-bottom: 5px;
  }

  .setting-hint {
    margin-left: 0;
  }
}
