/* ================================================
   KOUlucka - Ana Stil Dosyası
   Karanlık tema, modern tasarım
   ================================================ */

/* ------
   CSS Değişkenleri (Design Tokens)
   ------ */
:root {
  /* Renkler - Koyu tema */
  --bg-primary:    #0d1117;
  --bg-secondary:  #161b22;
  --bg-card:       #1c2230;
  --bg-card-hover: #222b3a;
  --bg-input:      #0d1117;

  /* Vurgu renkleri */
  --accent-green:  #2ea043;
  --accent-blue:   #388bfd;
  --accent-orange: #d29922;
  --accent-red:    #da3633;
  --accent-purple: #8b949e;

  /* Metin renkleri */
  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  /* Kenarlıklar */
  --border:        #30363d;
  --border-active: #388bfd;

  /* Köşe yuvarlaklıkları */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Gölgeler */
  --shadow-card: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.6);

  /* Geçiş süresi */
  --transition: 0.2s ease;

  /* Font */
  --font: 'Inter', system-ui, -apple-system, sans-serif;

  /* Maksimum genişlik */
  --max-width: 1200px;
}

/* ------
   Reset & Base
   ------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------
   HEADER
   ------ */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  font-size: 32px;
  line-height: 1;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.last-update {
  font-size: 11px;
  color: var(--text-muted);
}

/* ------
   BADGES (Çevrimiçi/Çevrimdışı)
   ------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  transition: var(--transition);
}

.badge-online {
  background: rgba(46, 160, 67, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(46, 160, 67, 0.3);
}

.badge-offline {
  background: rgba(218, 54, 51, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(218, 54, 51, 0.3);
}

/* ------
   ANA İÇERİK
   ------ */
.main-content {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ------
   BÖLÜM BAŞLIĞI
   ------ */
.section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ------
   ALERT BANNER
   ------ */
.alert-banner {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-banner.alert-error {
  background: rgba(218, 54, 51, 0.1);
  border: 1px solid rgba(218, 54, 51, 0.3);
  color: #ff7b72;
}

.alert-banner.alert-success {
  background: rgba(46, 160, 67, 0.1);
  border: 1px solid rgba(46, 160, 67, 0.3);
  color: #56d364;
}

.alert-banner.hidden {
  display: none;
}

/* ------
   SENSÖR KARTLARI
   ------ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  box-shadow: var(--shadow-card);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(56, 139, 253, 0.3);
}

.card-sensor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.card-icon {
  font-size: 28px;
  line-height: 1;
}

.card-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  transition: color var(--transition);
}

.card-unit {
  font-size: 12px;
  color: var(--text-muted);
}

/* Değer renkleri (sıcaklık yüksekse kırmızı, etc.) */
.card-value.value-high { color: var(--accent-orange); }
.card-value.value-critical { color: var(--accent-red); }
.card-value.value-good { color: var(--accent-green); }

/* ------
   KONTROL PANELİ
   ------ */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow var(--transition);
  box-shadow: var(--shadow-card);
}

.control-card:hover {
  box-shadow: var(--shadow-hover);
}

.control-card-wide {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.control-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-icon {
  font-size: 20px;
}

.control-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.control-body {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control-body-col {
  flex-direction: column;
  align-items: stretch;
}

.control-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #30363d;
  border-radius: 28px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 4px;
  bottom: 4px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-green);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

.toggle-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 50px;
}

/* Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  transition: background var(--transition);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(56, 139, 253, 0.2);
  transition: box-shadow var(--transition);
}

.slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 6px rgba(56, 139, 253, 0.3);
}

.slider-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.slider-current {
  font-weight: 700;
  color: var(--accent-blue);
}

/* Sayı Girdisi */
.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.num-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: border-color var(--transition);
}

.num-input:focus {
  border-color: var(--border-active);
}

.input-unit {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ------
   BUTONLAR
   ------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

.btn-primary:hover {
  background: #58a6ff;
  border-color: #58a6ff;
}

.btn-success {
  background: rgba(46, 160, 67, 0.15);
  color: var(--accent-green);
  border-color: rgba(46, 160, 67, 0.3);
}

.btn-success:hover {
  background: rgba(46, 160, 67, 0.25);
}

.btn-danger {
  background: rgba(218, 54, 51, 0.15);
  color: var(--accent-red);
  border-color: rgba(218, 54, 51, 0.3);
}

.btn-danger:hover {
  background: rgba(218, 54, 51, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Buton Grubu */
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Seçili buton durumu */
.btn-option {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-option:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-option.active {
  background: rgba(56, 139, 253, 0.15);
  color: var(--accent-blue);
  border-color: rgba(56, 139, 253, 0.4);
}

/* ------
   SİSTEM DURUMU
   ------ */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.status-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.last-cmd-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.last-cmd-label {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ------
   OLAY LOGU
   ------ */
.log-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: 'Courier New', monospace;
  transition: background var(--transition);
}

.log-entry:hover {
  background: var(--bg-card);
}

.log-time {
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 140px;
}

.log-type {
  font-weight: 600;
  flex-shrink: 0;
  min-width: 100px;
}

.log-type-sensor { color: var(--accent-blue); }
.log-type-command { color: var(--accent-orange); }
.log-type-auto { color: var(--accent-purple); }
.log-type-error { color: var(--accent-red); }

.log-message {
  color: var(--text-secondary);
}

.log-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
  font-size: 13px;
}

/* ------
   FOOTER
   ------ */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ------
   RESPONSIVE (Mobil Uyum)
   ------ */
@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-content {
    padding: 16px;
  }

  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .controls-grid {
    grid-template-columns: 1fr;
  }

  .control-card-wide {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ------
   ANİMASYONLAR
   ------ */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* Sayı güncelleme animasyonu */
@keyframes numberUpdate {
  0% { transform: scale(1.1); color: var(--accent-blue); }
  100% { transform: scale(1); }
}

.value-updated {
  animation: numberUpdate 0.3s ease-out;
}
