/* ==================== SmartDiji - Tema Değişkenleri ==================== */
:root {
  --bg: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.8);
  --bg-card-hover: rgba(51, 65, 85, 0.6);
  --border: rgba(148, 163, 184, 0.15);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --online: #22c55e;
  --offline: #64748b;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --radius: 16px;
  --radius-sm: 12px;
}

body.light {
  --bg: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(241, 245, 249, 0.9);
  --border: rgba(30, 41, 59, 0.12);
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

/* ==================== Reset & Base ==================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background 0.3s, color 0.3s;
}

/* ==================== App Layout ==================== */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==================== Header ==================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  background: var(--bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

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

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #22c55e);
  box-shadow: var(--shadow);
}

.header-brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.btn-icon {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
}

.btn-icon:active {
  transform: scale(0.96);
}

/* ==================== Status Badge ==================== */
.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--offline);
  animation: pulse 2s infinite;
}

.status-badge.online .status-dot {
  background: var(--online);
}

.status-badge.offline .status-dot {
  background: var(--danger);
}

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

/* ==================== Info Cards ==================== */
.info-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.info-icon {
  font-size: 1.5rem;
}

.info-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 1rem;
  font-weight: 700;
}

/* ==================== Cards ==================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

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

.card-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-badge {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent);
}

/* ==================== Counter ==================== */
.counter-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.counter-display {
  font-size: 3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 100px;
  text-align: center;
  color: var(--accent);
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  padding: 12px 20px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-inc, .btn-dec {
  width: 52px;
  height: 52px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-inc {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.btn-dec {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.btn-inc:hover, .btn-dec:hover {
  transform: scale(1.05);
}

.btn-reset {
  width: 100%;
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  margin-bottom: 12px;
}

.counter-set {
  display: flex;
  gap: 8px;
}

.counter-set input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.counter-set input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.btn-primary:hover {
  background: rgba(56, 189, 248, 0.3);
}

/* ==================== Relay ==================== */
.relay-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.relay-item {
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.relay-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.relay-status {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.relay-status.on {
  color: var(--success);
}

.relay-status.off {
  color: var(--text-muted);
}

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

.relay-buttons .btn {
  flex: 1;
  padding: 10px;
  font-size: 0.9rem;
}

.btn-on {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.btn-on.active {
  background: var(--success);
  color: white;
}

.btn-off {
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-off.active {
  background: var(--danger);
  color: white;
}

/* ==================== Messages ==================== */
.message-section {
  margin-bottom: 16px;
}

.message-section:last-child {
  margin-bottom: 0;
}

.message-section label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.input-row input {
  flex: 1;
  min-width: 120px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.input-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

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

/* ==================== Details ==================== */
.card-small .card-header {
  margin-bottom: 12px;
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.detail-item span:first-child {
  color: var(--text-muted);
}

/* ==================== Footer ==================== */
.footer {
  margin-top: auto;
  padding: 20px 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==================== Mobile ==================== */
@media (min-width: 520px) {
  .app {
    max-width: 520px;
    padding: 0 24px 32px;
  }
}

@media (max-width: 380px) {
  .info-cards {
    grid-template-columns: 1fr;
  }

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

  .counter-display {
    font-size: 2.5rem;
  }
}
