* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}
.top-nav {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-tabs {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  border-bottom: 2px solid #e2e8f0;
}
.nav-tab {
  flex: 1;
  padding: 16px 24px;
  background: transparent;
  border: none;
  color: #718096;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border-bottom: 3px solid transparent;
}
.nav-tab:hover {
  color: #4a5568;
  background: rgba(102, 126, 234, 0.05);
}
.nav-tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
  background: rgba(102, 126, 234, 0.08);
}
.page-container {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
}
.container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 25px; /* Még kisebb padding */
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 95%; /* Százalékos érték a jobb illeszkedésért */
  width: 100%;
  margin: 0 auto;
}
.page-content {
  display: none;
}
.page-content.active {
  display: block;
}
.control-grid {
  display: grid !important;
  grid-template-columns: 1fr 2fr 1fr !important; /* Egyszerű arány: kamerák 2x akkora hely */
  gap: 15px !important;
  margin-top: 20px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* Responsive - kisebb képernyőkön */
@media (max-width: 1400px) {
  .control-grid {
    grid-template-columns: 0.8fr 2fr 0.8fr !important;
    gap: 10px !important;
  }
}

@media (max-width: 1200px) {
  .control-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Biztosítjuk, hogy a grid gyerekek ne kapjanak flex tulajdonságokat */
.control-grid > div {
  display: block !important;
}

/* Alapértelmezett order - ÚJ SORREND */
#controlsColumn {
  order: 1 !important; /* Vezérlés első */
}

#cameraColumn {
  order: 2 !important;
  display: flex !important; /* Flex helyett grid - egyszerűbb */
  flex-direction: row !important;
  gap: 10px !important;
  align-items: flex-start !important;
  justify-content: center !important; /* Középre igazítás alapból */
  flex-wrap: wrap !important; /* Ha kicsi a hely, tördelődik */
}

/* Fix méret minden kamera konténernek - MINDIG ugyanaz */
#camera1Container, #camera2Container {
  width: 100% !important;
  max-width: 500px !important;
  min-height: 450px !important;
  flex-shrink: 0 !important;
}

/* Két kamera esetén osztsuk meg a helyet */
@media (min-width: 1200px) {
  #camera1Container, #camera2Container {
    width: calc(50% - 5px) !important;
  }
}

#keyboardColumn {
  order: 3 !important; /* Billentyűzet harmadik */
}

/* Tablet és mobilon egymás alá */
@media (max-width: 1024px) {
  #cameraColumn {
    flex-direction: column !important;
    align-items: center !important;
  }
  
  #camera1Container, #camera2Container {
    width: 100% !important;
    max-width: 500px !important;
  }
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 20px;
}

/* Beállítások tab navigáció */
.settings-tab {
  flex: 1;
  padding: 14px 20px;
  background: transparent;
  border: none;
  color: #718096;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border-bottom: 3px solid transparent;
}
.settings-tab:hover {
  color: #4a5568;
  background: rgba(102, 126, 234, 0.05);
}
.settings-tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
  background: rgba(102, 126, 234, 0.08);
}

/* Beállítások tab tartalom */
.settings-tab-content {
  display: none;
}
.settings-tab-content.active {
  display: block;
}
@media (max-width: 1024px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
  /* control-grid KIKOMMENTÁLVA - nem törjük el a custom layoutot */
}
@media (min-width: 1025px) and (max-width: 1400px) {
  /* control-grid KIKOMMENTÁLVA - nem törjük el a custom layoutot */
}
.control-section-title {
  background: #667eea;
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
  min-height: 40px; /* Fix magasság */
  display: flex;
  align-items: center;
  justify-content: center;
}
.control-description {
  color: #718096;
  font-size: 13px;
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.5;
  min-height: 40px; /* Fix magasság */
  display: flex;
  align-items: center;
  justify-content: center;
}
h2 {
  color: #2d3748;
  font-size: 32px;
  margin-bottom: 10px;
  text-align: center;
  font-weight: 700;
}
.status-bar {
  background: #edf2f7;
  padding: 16px 20px;
  border-radius: 12px;
  margin: 20px 0 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fc8181;
}
.status-indicator.connected {
  background: #48bb78;
}
.motor-control-panel {
  background: #f7fafc;
  border-radius: 16px;
  padding: 30px;
  margin: 20px 0;
}
.direction-control {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.direction-btn {
  flex: 1;
  padding: 16px;
  border: 3px solid #e2e8f0;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  font-weight: 600;
  font-size: 16px;
  color: #4a5568;
}
.direction-btn.active {
  border-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  color: #667eea;
}
.turn-control {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.turn-btn {
  flex: 1;
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
  color: #4a5568;
}
.turn-btn.active {
  background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%);
  color: white;
}
.speed-buttons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin: 20px 0;
}
.speed-btn {
  padding: 20px 10px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
  color: #4a5568;
}
.speed-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}
.speed-btn.stop {
  background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
  color: white;
}
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.login-overlay.hidden {
  display: none;
}
.login-box {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
}
.input-group {
  margin-bottom: 20px;
}
.input-group label {
  display: block;
  color: #4a5568;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
}
.input-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
}
.login-button {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.error-message {
  background: #fc8181;
  color: white;
  padding: 12px;
  border-radius: 8px;
  margin-top: 15px;
  text-align: center;
  font-weight: 600;
  display: none;
}
.error-message.show {
  display: block;
}

/* Kamera stílusok */
.camera-section {
  background: #f7fafc;
  border-radius: 16px;
  padding: 12px;
  text-align: center;
  position: relative;
  height: 350px; /* FIX MAGASSÁG - nem min-height! */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden; /* Semmi ne lógjon ki */
}

/* Kamera placeholder - KIKAPCSOLVA, mert ugrálást okoz */
.camera-section::before {
  display: none !important;
}
.camera-frame {
  width: 380px !important; /* FIX szélesség */
  height: 285px !important; /* FIX magasság */
  border-radius: 12px;
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  margin: 0 auto;
  display: block !important;
  object-fit: contain;
  flex-shrink: 0 !important; /* Ne változzon a mérete */
  color: transparent !important; /* Alt szöveg láthatatlan */
  font-size: 0 !important; /* Alt szöveg mérete 0 */
  text-indent: -9999px !important; /* Alt szöveg kívül */
  overflow: hidden !important; /* Semmi ne lógjon ki */
}

/* Loading állapot - amikor még nincs kép */
.camera-frame:not([src]),
.camera-frame[src=""] {
  /* Semmi animáció vagy változás */
  animation: none !important;
  /* Háttér mindig ugyanaz */
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%) !important;
}

/* Ha nincs kép, ne jelenjen meg broken image ikon */
.camera-frame::before,
.camera-frame::after {
  display: none !important;
  content: none !important;
}

@keyframes camera-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.8;
  }
}
.camera-status {
  color: #4a5568;
  font-size: 14px;
  margin-top: 10px;
  font-weight: 600;
  height: 24px; /* Fix magasság */
  line-height: 24px; /* Központosítás */
  display: block;
  width: 100%; /* Teljes szélesség */
  text-align: center;
}

/* Beállítások stílusok */
.settings-card {
  background: #f7fafc;
  border-radius: 16px;
  padding: 24px;
}
.settings-card h3 {
  color: #2d3748;
  font-size: 18px;
  margin-bottom: 16px;
  font-weight: 700;
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 2px solid #e2e8f0;
}
.slider-group {
  margin: 20px 0;
}
.slider-label {
  color: #4a5568;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.slider-value {
  color: #667eea;
  font-weight: 700;
  font-size: 16px;
}
input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: #e2e8f0;
  outline: none;
  -webkit-appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  cursor: pointer;
  border: none;
}
.mode-selector {
  display: flex;
  gap: 10px;
  margin: 15px 0;
}
.mode-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  background: white;
  cursor: pointer;
  font-weight: 600;
  color: #4a5568;
  transition: all 0.3s ease;
}
.mode-btn.active {
  border-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  color: #667eea;
}
.save-button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 15px;
}
.save-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

/* Billentyűzet kiosztás */
.keyboard-mapping {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 15px 0;
}
.key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  padding: 12px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
}
.key-label {
  color: #4a5568;
  font-weight: 600;
  font-size: 13px;
}
.key-box {
  min-width: 60px;
  padding: 6px 12px;
  background: #edf2f7;
  border: 2px solid #cbd5e0;
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  color: #2d3748;
  font-size: 14px;
}
.key-box.recording {
  background: #fef5e7;
  border-color: #f6ad55;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.key-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.key-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.key-btn.set {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}
.key-btn.clear {
  background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
  color: white;
}

/* Konfiguráció menedzsment */
.config-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}
.config-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}
.config-btn.export {
  background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
  color: white;
}
.config-btn.import {
  background: linear-gradient(135deg, #9f7aea 0%, #805ad5 100%);
  color: white;
}
.config-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Vezérlés lap billentyűzet megjelenítő */
.keyboard-display {
  background: #f7fafc;
  border-radius: 16px;
  padding: 20px;  /* Csökkentve 24px-ről */
  margin-top: 20px;
}
.keyboard-display h3 {
  color: #2d3748;
  font-size: 18px;
  margin-bottom: 16px;  /* Csökkentve 20px-ről */
  font-weight: 700;
  text-align: center;
}
.keyboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;  /* Csökkentve 15px-ről */
  margin-bottom: 16px;  /* Csökkentve 20px-ről */
}

/* Egyoszlopos verzió nagyobb billentyűzet számára */
.keyboard-grid.single-column {
  grid-template-columns: 1fr !important;
  gap: 15px;
}
.keyboard-group {
  background: white;
  border-radius: 12px;
  padding: 12px;  /* Csökkentve 16px-ről */
  border: 2px solid #e2e8f0;
  margin-bottom: 10px;
}
.keyboard-group h4 {
  color: #667eea;
  font-size: 13px;  /* Csökkentve 14px-ről */
  font-weight: 700;
  margin-bottom: 10px;  /* Csökkentve 12px-ről */
  text-align: center;
  text-transform: uppercase;
}
.keyboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;  /* Csökkentve 10px-ről */
  border-bottom: 1px solid #f7fafc;
  gap: 15px;  /* Csökkentve 25px-ről */
}
.keyboard-item:last-child {
  border-bottom: none;
}
.keyboard-item-label {
  color: #718096;
  font-size: 12px;  /* Csökkentve 13px-ről */
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.keyboard-item-key {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 5px 16px;  /* Csökkentve 6px 24px-ről */
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;  /* Csökkentve 14px-ről */
  min-width: 80px;  /* Csökkentve 110px-ről */
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .keyboard-mapping {
    grid-template-columns: 1fr;
  }
  .keyboard-grid {
    grid-template-columns: 1fr;
  }
  
  /* Mobilon kisebb kamera méret */
  .camera-frame {
    width: 280px !important;
    height: 210px !important;
  }
  
  .camera-section {
    height: 280px !important;
  }
  
  #camera1Container, #camera2Container {
    min-height: 360px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  /* Tablet méret */
  .camera-frame {
    width: 320px !important;
    height: 240px !important;
  }
  
  .camera-section {
    height: 300px !important;
    padding: 10px;
  }
  
  #camera1Container, #camera2Container {
    min-height: 380px !important;
  }
}

/* Relé vezérlő stílusok */
.relay-control-item {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.relay-control-item:hover {
  border-color: #cbd5e0;
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

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

.relay-icon {
  font-size: 24px;
  margin-right: 10px;
}

.relay-name {
  font-size: 16px;
  font-weight: 700;
  color: #2d3748;
}

.relay-status {
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #4a5568;
}

.relay-status.on {
  background: #c6f6d5;
  color: #22543d;
}

.relay-buttons {
  display: flex;
  gap: 10px;
}

.relay-btn {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
}

.relay-btn.on {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  color: white;
}

.relay-btn.on:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(72, 187, 120, 0.3);
}

.relay-btn.on:active {
  transform: translateY(0);
}

.relay-btn.off {
  background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
  color: white;
}

.relay-btn.off:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(245, 101, 101, 0.3);
}

.relay-btn.off:active {
  transform: translateY(0);
}

.emergency-relay-btn {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

.emergency-relay-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(229, 62, 62, 0.4);
}

.emergency-relay-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(229, 62, 62, 0.3);
}