/* ==========================================================================
   PHONE MASTER — ESTILOS PRINCIPAIS (CSS3 MODERNO MOBILE-FIRST)
   Paleta: #080F1C (Fundo), #111C2D (Cards), #287BFF (Azul), #22D3EE (Ciano)
   ========================================================================== */

:root {
  --bg-main: #080F1C;
  --bg-card: #111C2D;
  --bg-card-hover: #16243A;
  --bg-elevated: #1A2B44;
  --border-subtle: rgba(40, 123, 255, 0.16);
  --border-active: rgba(34, 211, 238, 0.45);
  
  --color-primary: #287BFF;
  --color-primary-hover: #1A6AE8;
  --color-cyan: #22D3EE;
  --color-cyan-glow: rgba(34, 211, 238, 0.25);
  
  --color-success: #10B981;
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-warning: #F59E0B;
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-danger: #EF4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);
  
  --text-main: #FFFFFF;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --nav-height: 68px;
  --header-height: 64px;
}

/* Light Mode Overrides (Optional user toggle) */
body.light-theme {
  --bg-main: #F1F5F9;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-elevated: #E2E8F0;
  --border-subtle: rgba(40, 123, 255, 0.2);
  --border-active: rgba(34, 211, 238, 0.8);
  --text-main: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-height) + 24px);
}

/* App Shell Container */
.app-container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(8, 15, 28, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-logo-img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  box-shadow: 0 0 12px var(--color-cyan-glow);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #FFFFFF 30%, var(--color-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(17, 28, 45, 0.8);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.status-chip.online .status-dot {
  background-color: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}
.status-chip.offline .status-dot {
  background-color: var(--color-danger);
  box-shadow: 0 0 8px var(--color-danger);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

/* Install PWA Button in Header */
.btn-install-header {
  background: linear-gradient(135deg, var(--color-primary), #1B65DF);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(40, 123, 255, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

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

/* Offline Alert Banner */
.offline-banner {
  background: linear-gradient(90deg, #92400E, #B45309);
  color: #FFF;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 16px;
  text-align: center;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.offline-banner.visible {
  display: flex;
}

/* Install Prompt Banner (Android PWA flow) */
.install-banner {
  margin: 12px 0;
  background: var(--bg-card);
  border: 1px solid var(--color-cyan);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(34, 211, 238, 0.15);
}

.install-banner-text h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #FFF;
}
.install-banner-text p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Cards & Components */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  transition: border-color 0.2s, transform 0.15s;
}

.card:hover {
  border-color: rgba(40, 123, 255, 0.35);
}

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

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(40, 123, 255, 0.12);
  color: var(--color-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), #1A68E5);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(40, 123, 255, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #3785FF, #2374F5);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
  border-color: var(--color-cyan);
}

.btn-cyan {
  background: linear-gradient(135deg, #06B6D4, #0891B2);
  color: #FFFFFF;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}
.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.badge-neutral {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

/* Navigation: Fixed Bottom Nav Bar (Android App Look) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(17, 28, 45, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
  max-width: 680px;
  margin: 0 auto;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  transition: color 0.15s;
  flex: 1;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  transition: transform 0.15s, color 0.15s;
}

.nav-item.active {
  color: var(--color-cyan);
}

.nav-item.active svg {
  transform: translateY(-2px);
  color: var(--color-cyan);
}

/* Floating AI Action Button (Phone Master AI) */
.fab-ai {
  position: fixed;
  bottom: calc(var(--nav-height) + 14px);
  right: 18px;
  z-index: 45;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-cyan), var(--color-primary));
  color: #FFFFFF;
  border: none;
  box-shadow: 0 4px 18px rgba(34, 211, 238, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fab-ai:active {
  transform: scale(0.92);
}

.fab-ai-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #10B981;
  color: #FFF;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
  border: 2px solid var(--bg-main);
}

/* Tab Views */
.tab-content {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
  padding-top: 14px;
}

.tab-content.active {
  display: block;
}

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

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* Metric Display Blocks */
.metric-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.metric-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.metric-unit {
  font-size: 0.72rem;
  color: var(--color-cyan);
  font-weight: 600;
}

/* Quick Tool Action Tile */
.tool-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.tool-tile:hover, .tool-tile:active {
  border-color: var(--color-cyan);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.tool-tile-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.12);
  color: var(--color-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-tile-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Progress bar */
.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-primary), var(--color-cyan));
  transition: width 0.3s ease;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 9, 18, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: #FFF;
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Form Controls */
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  margin-top: 6px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-cyan);
}

/* Diagnostic Items */
.diagnostic-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.diagnostic-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.diagnostic-item-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.diagnostic-item-desc {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

.diagnostic-item-details {
  font-size: 0.8rem;
  color: var(--color-cyan);
  margin-top: 6px;
  font-weight: 500;
}

.diagnostic-item-recommendation {
  font-size: 0.74rem;
  color: #CBD5E1;
  background: rgba(0, 0, 0, 0.25);
  border-left: 2px solid var(--color-primary);
  padding: 6px 8px;
  margin-top: 6px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Chat Assistant (Phone Master AI) */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 480px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.86rem;
  line-height: 1.45;
  word-break: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #FFF;
  border-bottom-right-radius: 4px;
}

.chat-bubble.bot {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: #F8FAFC;
  border-bottom-left-radius: 4px;
}

.chat-prompt-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  margin-bottom: 8px;
  scrollbar-width: none;
}

.chat-prompt-chips::-webkit-scrollbar {
  display: none;
}

.prompt-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--color-cyan);
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
.prompt-chip:hover {
  border-color: var(--color-cyan);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Responsive adjust */
@media (min-width: 641px) {
  body {
    padding-bottom: 30px;
  }
  .bottom-nav {
    border-radius: var(--radius-lg);
    bottom: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
  }
  .fab-ai {
    bottom: calc(var(--nav-height) + 26px);
  }
}

/* Print styles for export report */
@media print {
  body {
    background: #FFF !important;
    color: #000 !important;
  }
  .app-header, .bottom-nav, .fab-ai, .btn-install-header, .btn {
    display: none !important;
  }
  .card {
    border: 1px solid #CCC !important;
    background: #FFF !important;
    color: #000 !important;
    page-break-inside: avoid;
  }
}
