/* ==========================================================================
   Aqua Express - System Logs & Monitoring Dashboard
   Theme: Modern Dark Operations Center
   ========================================================================== */

:root {
  --bg-main: #0c0f17;
  --bg-surface: #141923;
  --bg-surface-alt: #1a2232;
  --bg-card: #182030;
  --bg-hover: #222c3f;
  
  --border-color: #263347;
  --border-light: #32435e;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-indigo: #6366f1;
  
  --status-normal: #10b981;
  --status-normal-bg: rgba(16, 185, 129, 0.12);
  --status-normal-border: rgba(16, 185, 129, 0.3);
  
  --status-fault: #ef4444;
  --status-fault-bg: rgba(239, 68, 68, 0.15);
  --status-fault-border: rgba(239, 68, 68, 0.4);
  
  --status-warning: #f59e0b;
  --status-warning-bg: rgba(245, 158, 11, 0.15);
  
  --sidebar-width: 320px;
  --header-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* App Header */
.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 20;
  flex-shrink: 0;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.3);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-surface-alt);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-normal);
  box-shadow: 0 0 8px var(--status-normal);
  animation: pulse 2s infinite ease-in-out;
}

.pulse-dot.offline {
  background: var(--status-fault);
  box-shadow: 0 0 8px var(--status-fault);
  animation: none;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.btn-icon {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  color: #fff;
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-icon.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
}

/* App Main Layout */
.app-container {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.sidebar-search {
  padding: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.45rem 0.65rem 0.45rem 2rem;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-cyan);
}

.channels-header {
  padding: 0.75rem 1rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channels-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  border: 1px solid transparent;
}

.channel-item:hover {
  background: var(--bg-hover);
}

.channel-item.active {
  background: var(--bg-surface-alt);
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

.channel-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--status-normal);
  box-shadow: 0 0 6px var(--status-normal);
}

.channel-item.status-fault .channel-status-dot {
  background: var(--status-fault);
  box-shadow: 0 0 8px var(--status-fault);
  animation: pulse 1.5s infinite;
}

.channel-item.status-offline .channel-status-dot {
  background: var(--text-muted);
  box-shadow: none;
}

.channel-info {
  flex: 1;
  min-width: 0;
}

.channel-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.channel-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-tag {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-main);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

.channel-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.channel-item.status-fault .channel-subtext {
  color: #fca5a5;
}

.badge-fault {
  background: var(--status-fault);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

/* Chat / Log Feed Area */
.feed-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  min-width: 0;
  position: relative;
}

.feed-header {
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.feed-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.feed-channel-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-status-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.feed-status-pill.normal {
  background: var(--status-normal-bg);
  color: var(--status-normal);
  border: 1px solid var(--status-normal-border);
}

.feed-status-pill.fault {
  background: var(--status-fault-bg);
  color: var(--status-fault);
  border: 1px solid var(--status-fault-border);
}

.feed-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Filter Toolbar */
.filter-toolbar {
  padding: 0.5rem 1.25rem;
  background: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-sm {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  outline: none;
}

.input-sm:focus {
  border-color: var(--accent-cyan);
}

.btn-filter {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

.btn-filter:hover {
  background: var(--bg-hover);
  color: #fff;
}

.btn-filter.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

/* Messages Feed */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.message-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.message-card:hover {
  border-color: var(--border-light);
  background: #1b2436;
}

.message-card.fault {
  border-left-color: var(--status-fault);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.08) 0%, var(--bg-card) 25%);
  border-color: rgba(239, 68, 68, 0.3);
}

.message-card.restored {
  border-left-color: var(--status-normal);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.06) 0%, var(--bg-card) 25%);
  border-color: rgba(16, 185, 129, 0.25);
}

.msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  gap: 0.5rem;
}

.msg-sender-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.msg-badge-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.msg-badge-type.fault {
  background: var(--status-fault-bg);
  color: #f87171;
  border: 1px solid var(--status-fault-border);
}

.msg-badge-type.restored {
  background: var(--status-normal-bg);
  color: #34d399;
  border: 1px solid var(--status-normal-border);
}

.msg-channel-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
}

.msg-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.msg-content {
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.msg-fault-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.25rem;
  color: #fca5a5;
  font-weight: 500;
}

.msg-fault-item svg {
  flex-shrink: 0;
  margin-top: 4px;
}

.msg-restored-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #6ee7b7;
  font-weight: 600;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

/* PIN Auth Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 17, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.pin-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.pin-modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-size: 1.5rem;
}

.pin-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.pin-modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.pin-input {
  width: 100%;
  background: var(--bg-main);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-size: 1.5rem;
  letter-spacing: 0.5rem;
  text-align: center;
  color: #fff;
  outline: none;
  margin-bottom: 1.25rem;
  transition: border-color 0.2s;
}

.pin-input:focus {
  border-color: var(--accent-cyan);
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.92;
}

.pin-error {
  color: var(--status-fault);
  font-size: 0.8rem;
  margin-top: 0.75rem;
  display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    z-index: 30;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .btn-mobile-menu {
    display: flex !important;
  }
}

.btn-mobile-menu {
  display: none;
}
