/**
 * Autowater - Unified Stylesheet
 * Clean, professional IoT interface
 */

/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Colors - Industrial IoT Theme */
  --primary: #00D9FF;
  --primary-dark: #00A8CC;
  --success: #00FF88;
  --success-dark: #00CC6A;
  --warning: #FFD700;
  --danger: #FF4444;
  --bg: #0A0A0A;
  --surface: #1A1A1A;
  --surface-light: #2A2A2A;
  --text: #FFFFFF;
  --text-secondary: #AAAAAA;
  --border: #333333;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Border radius */
  --radius: 8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.header {
  background: var(--surface);
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-lg);
}

/* ===== BUTTONS ===== */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 217, 255, 0.3);
}

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #3A3A3A;
  border-color: var(--text-secondary);
}

.btn-success {
  background: var(--success);
  color: var(--bg);
}

.btn-success:hover {
  background: var(--success-dark);
  box-shadow: 0 4px 12px rgba(0, 255, 136, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: var(--text);
}

.btn-danger:hover {
  background: #CC0000;
  box-shadow: 0 4px 12px rgba(255, 68, 68, 0.3);
}

.btn-large {
  padding: 1.25rem 2rem;
  font-size: 1.25rem;
}

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

/* ===== DEVICE CARD ===== */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: var(--spacing-md);
}

.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  transition: all 0.2s ease;
}

.device-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.device-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border);
}

.device-name {
  font-size: 1.25rem;
  font-weight: 500;
}

.device-info {
  margin-bottom: var(--spacing-md);
}

.info-item {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-xs) 0;
}

.info-label {
  color: var(--text-secondary);
}

.info-value {
  font-family: 'Courier New', monospace;
}

.device-actions {
  display: flex;
  gap: var(--spacing-xs);
}

.device-actions .btn {
  flex: 1;
}

/* ===== STATUS BADGES ===== */
.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.status-online {
  background: rgba(0, 255, 136, 0.2);
  color: var(--success);
  border: 1px solid var(--success);
}

.status-offline {
  background: rgba(255, 68, 68, 0.2);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* ===== STATES ===== */
.loading-state,
.error-state,
.empty-state {
  text-align: center;
  padding: var(--spacing-xl);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--spacing-md);
}

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

.error-icon,
.empty-icon {
  font-size: 3rem;
  margin-bottom: var(--spacing-sm);
}

.error-state {
  color: var(--danger);
}

.error-state h3 {
  margin-bottom: var(--spacing-sm);
}

.empty-state {
  color: var(--text-secondary);
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  margin-bottom: var(--spacing-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 0.75rem;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.1);
}

.form-input::placeholder {
  color: var(--text-secondary);
}

/* ===== CONTROL PANEL ===== */
.control-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

.control-panel h2 {
  margin-bottom: var(--spacing-md);
}

.control-buttons {
  display: flex;
  gap: var(--spacing-md);
  justify-content: center;
}

.control-status {
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm);
  border-radius: var(--radius);
  text-align: center;
  font-weight: 500;
}

.control-status.success {
  background: rgba(0, 255, 136, 0.2);
  color: var(--success);
  border: 1px solid var(--success);
}

.control-status.error {
  background: rgba(255, 68, 68, 0.2);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* ===== LOG VIEWER ===== */
.log-viewer {
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  height: 500px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
}

.log-entry {
  padding: 0.25rem 0;
  border-bottom: 1px solid #222;
}

.log-time {
  color: #666;
}

.log-topic {
  color: var(--primary);
}

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

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
  position: fixed;
  bottom: var(--spacing-lg);
  right: var(--spacing-lg);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  background: var(--success);
  color: var(--bg);
}

.toast-error {
  background: var(--danger);
}

.toast-info {
  background: var(--primary);
  color: var(--bg);
}

/* ===== WIFI CONFIG ===== */
.wifi-slot {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.wifi-slot h3 {
  margin-bottom: var(--spacing-sm);
  color: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

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

  .control-buttons {
    flex-direction: column;
  }

  .device-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}
