/* ============================================================
   MCiMonitor by MCiTech — Estilos Principais
   Identidade visual MCiTech: Azul #0934C0 / Navy #0F175E
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary:       #0934C0;
  --primary-dark:  #0F175E;
  --primary-light: #1998D5;
  --primary-glow:  rgba(9, 52, 192, 0.15);
  --accent:        #1998D5;
  --accent2:       #00c6ff;

  --bg:       #f0f4ff;
  --surface:  #ffffff;
  --surface2: #e8eeff;
  --text:     #0F175E;
  --text-secondary: #6b7ca4;
  --border:   #d0d9f0;
  --shadow:   0 2px 12px rgba(9, 52, 192, 0.1);
  --radius:   14px;
  --radius-sm: 10px;

  /* Severidades Zabbix */
  --sev-0: #97aab3;
  --sev-1: #4d7fff;
  --sev-2: #f5a623;
  --sev-3: #f07020;
  --sev-4: #e04040;
  --sev-5: #c0000a;

  --host-ok:      #00b894;
  --host-problem: #e04040;
  --host-unknown: #97aab3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #07102e;
    --surface:  #112050;
    --surface2: #162660;
    --text:     #dde8ff;
    --text-secondary: #8fa8d8;
    --border:   #1e3270;
    --shadow:   0 2px 16px rgba(0,0,0,0.4);
  }
}

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

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  /* impede scroll/overflow horizontal em toda a página */
  max-width: 100vw;
  overscroll-behavior: none;
}

/* ---- APP SHELL ---- */
#app { display: flex; flex-direction: column; height: 100vh; max-width: 600px; margin: 0 auto; }

/* ---- HEADER ---- */
.app-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--accent) 100%);
  color: white;
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  box-shadow: 0 3px 16px rgba(9, 52, 192, 0.4);
  position: relative;
  z-index: 10;
}

.app-header .header-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.header-divider {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.3);
  margin: 0 4px;
}

.header-app-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: white;
  flex: 1;
}

.header-app-name span {
  font-weight: 400;
  opacity: 0.85;
  font-size: 14px;
}

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

.btn-icon {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.25); }

.header-user {
  font-size: 11px;
  color: rgba(255,255,255,0.85);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255,255,255,0.15);
  padding: 3px 8px;
  border-radius: 12px;
}

/* ---- CONTEÚDO PRINCIPAL ---- */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 80px; /* padding-bottom para o bottom nav fixo */
  -webkit-overflow-scrolling: touch;
}

/* ---- BOTTOM NAV (fixo no fundo, sempre visível) ---- */
.bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: 0 auto;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(9,52,192,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 6px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  gap: 3px;
  transition: color 0.15s;
  position: relative;
  font-family: 'Inter', sans-serif;
}
.nav-item .nav-icon { font-size: 20px; }
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon {
  filter: drop-shadow(0 0 6px rgba(9,52,192,0.4));
}

.nav-item .badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 20px);
  background: var(--sev-5);
  color: white;
  border-radius: 10px;
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-weight: 700;
  border: 2px solid var(--surface);
}

/* ---- LOGIN ---- */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 24px;
  background: linear-gradient(160deg, var(--primary-dark) 0%, var(--primary) 50%, var(--accent) 100%);
}

.login-logo-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}

.login-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.login-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 24px;
  margin-bottom: 8px;
}

.login-app-name {
  font-size: 26px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.5px;
}

.login-app-name span {
  color: var(--accent2);
}

.login-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
  text-align: center;
}

.login-card {
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
}

.login-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 20px;
  text-align: center;
}

.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #c8d4ee;
  border-radius: var(--radius-sm);
  background: #f0f4ff;
  color: #0F175E;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  font-family: 'Inter', sans-serif;
}
.form-input::placeholder { color: #9aabcc; }
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(9,52,192,0.15);
  background: #ffffff;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  margin-top: 8px;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 16px rgba(9,52,192,0.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(9,52,192,0.45); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.error-msg {
  color: var(--sev-4);
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
  min-height: 18px;
}

.login-footer {
  margin-top: 24px;
  text-align: center;
  color: rgba(255,255,255,0.5);
  font-size: 11px;
}
.login-footer a { color: rgba(255,255,255,0.75); text-decoration: none; }

/* ---- SECTION HEADER ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.section-count {
  background: var(--primary);
  color: white;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
}

/* ---- CARTÕES DE ALERTA ---- */
.problem-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
  border-left: 4px solid var(--sev-0);
}

.problem-card[data-severity="0"] { border-color: var(--sev-0); }
.problem-card[data-severity="1"] { border-color: var(--sev-1); }
.problem-card[data-severity="2"] { border-color: var(--sev-2); }
.problem-card[data-severity="3"] { border-color: var(--sev-3); }
.problem-card[data-severity="4"] { border-color: var(--sev-4); }
.problem-card[data-severity="5"] { border-color: var(--sev-5); background: #fff5f5; }

@media (prefers-color-scheme: dark) {
  .problem-card[data-severity="5"] { background: #2a0a0a; }
}

.problem-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 6px;
}

.severity-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  color: white;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.sev-0 { background: var(--sev-0); }
.sev-1 { background: var(--sev-1); }
.sev-2 { background: var(--sev-2); color: #333; }
.sev-3 { background: var(--sev-3); }
.sev-4 { background: var(--sev-4); }
.sev-5 { background: var(--sev-5); }

.problem-host {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.problem-name {
  padding: 2px 14px 8px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.problem-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

.problem-time { font-size: 11px; color: var(--text-secondary); }
.problem-duration { font-size: 11px; color: var(--text-secondary); font-weight: 600; }

/* ---- DASHBOARD ---- */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  border-top: 3px solid var(--border);
}
.summary-card:active { transform: scale(0.97); }
.summary-card:hover { box-shadow: 0 4px 20px rgba(9,52,192,0.15); }

.summary-number {
  font-size: 38px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.summary-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.summary-card.disaster { border-top-color: var(--sev-5); }
.summary-card.disaster .summary-number { color: var(--sev-5); }
.summary-card.high { border-top-color: var(--sev-3); }
.summary-card.high .summary-number { color: var(--sev-3); }
.summary-card.warning { border-top-color: var(--sev-2); }
.summary-card.warning .summary-number { color: var(--sev-2); }
.summary-card.ok { border-top-color: var(--host-ok); }
.summary-card.ok .summary-number { color: var(--host-ok); }
.summary-card.hosts { border-top-color: var(--primary); }
.summary-card.hosts .summary-number { color: var(--primary); }

/* ---- HOSTS ---- */
.host-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.host-card:hover { box-shadow: 0 4px 20px rgba(9,52,192,0.15); }
.host-card:active { transform: scale(0.98); }

.host-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(0,184,148,0.15);
}
.host-status-dot.ok { background: var(--host-ok); box-shadow: 0 0 0 3px rgba(0,184,148,0.15); }
.host-status-dot.problem { background: var(--host-problem); box-shadow: 0 0 0 3px rgba(224,64,64,0.15); }
.host-status-dot.unknown { background: var(--host-unknown); box-shadow: none; }

.host-info { flex: 1; min-width: 0; }
.host-name {
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.host-group { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.host-ip { font-size: 11px; color: var(--accent); font-family: monospace; margin-top: 1px; }
.host-arrow { color: var(--border); font-size: 20px; font-weight: 300; }

/* ---- FILTROS ---- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;       /* chips passam para 2ª linha em vez de cortar */
  gap: 6px;
  margin-bottom: 14px;
}

.filter-chip {
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}
.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(9,52,192,0.3);
}

/* ---- GROUP SELECT ---- */
.group-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 14px;
  outline: none;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s;
}
.group-select:focus { border-color: var(--primary); }

/* ---- ITEMS ---- */
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-name { font-size: 13px; flex: 1; padding-right: 8px; color: var(--text-secondary); }
.item-value { font-size: 13px; font-weight: 700; font-family: monospace; color: var(--text); }

/* ---- VAZIO / LOADING ---- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; line-height: 1.5; }

.spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px;
}
.spinner::after {
  content: '';
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--primary-dark);
  color: white;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- NOTIFY BUTTON ---- */
.notify-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
  width: 100%;
  justify-content: center;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}
.notify-btn:hover { background: var(--primary); color: white; }
.notify-btn.subscribed { background: var(--primary); color: white; }

/* ---- SETTINGS CARDS ---- */
.settings-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.settings-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.settings-card-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-dark);
}

/* ---- BANNER MCITECH ---- */
.mcitech-banner {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s;
}
.mcitech-banner:active { transform: scale(0.98); }
.mcitech-banner img {
  height: 28px;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}
.mcitech-banner-text { flex: 1; }
.mcitech-banner-text strong {
  display: block;
  color: white;
  font-size: 13px;
  font-weight: 700;
}
.mcitech-banner-text span {
  color: rgba(255,255,255,0.7);
  font-size: 11px;
}
.mcitech-banner-arrow {
  color: rgba(255,255,255,0.6);
  font-size: 18px;
}

/* ---- POWERED BY ---- */
.powered-by {
  text-align: center;
  padding: 12px 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 11px;
}
.powered-by img {
  height: 16px;
  opacity: 0.6;
}

/* ---- REFRESH HINT ---- */
.refresh-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 8px;
  opacity: 0.7;
}

/* ---- SCROLL SUAVE ---- */
.app-content { scroll-behavior: smooth; }

/* ---- SETTINGS BUTTON NO HEADER ---- */
.btn-settings {
  font-size: 18px;
  width: 36px;
  height: 36px;
}

/* ---- SETTINGS OVERLAY / MODAL ---- */
.settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.settings-overlay.open {
  display: flex;
}

.settings-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 600px;
  border-radius: 20px 20px 0 0;
  padding: 8px 20px 32px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.settings-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 8px auto 20px;
}

.settings-sheet-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 20px;
  text-align: center;
}

.settings-user-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.settings-user-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: white;
  font-weight: 700;
  flex-shrink: 0;
}
.settings-user-info { flex: 1; }
.settings-user-name { font-size: 15px; font-weight: 700; color: var(--text); }
.settings-user-role { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.settings-action-btn {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  border: none;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.settings-action-btn:active { opacity: 0.75; }
.settings-action-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}
.settings-action-btn.danger {
  background: none;
  border: 1.5px solid var(--sev-4);
  color: var(--sev-4);
}
.settings-action-btn.secondary {
  background: var(--surface2);
  color: var(--text);
}

.settings-info-block {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---- ACK BUTTON & BADGE ---- */
.ack-btn {
  background: none;
  border: 1.5px solid var(--host-ok);
  color: var(--host-ok);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.ack-btn:active { background: var(--host-ok); color: white; }
.ack-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ack-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--host-ok);
  color: white;
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* ---- BACK BUTTON ---- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 14px;
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.back-btn:active { background: var(--surface2); }

/* ---- TOQUE MOBILE: remover highlight azul nos botões ---- */
button, a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ---- PROBLEM CARD HEADER: wrap em ecrãs muito pequenos ---- */
.problem-card-header {
  flex-wrap: wrap;
}

/* ---- ITEM VALUE: não deixar overflow ---- */
.item-value {
  max-width: 50%;
  word-break: break-all;
  text-align: right;
}
