/* ============================================================
   VISTO - Sistema de Vistorias de Imóveis
   CSS Principal
   ============================================================ */

:root {
  --primary: #1565C0;
  --primary-dark: #0D47A1;
  --primary-light: #1976D2;
  --secondary: #546E7A;
  --success: #2E7D32;
  --warning: #E65100;
  --danger: #C62828;
  --info: #0277BD;
  --bg: #F0F4F8;
  --sidebar-bg: #1A237E;
  --sidebar-text: #E8EAF6;
  --card-bg: #FFFFFF;
  --border: #CFD8DC;
  --text: #212121;
  --text-light: #546E7A;
  --header-h: 56px;
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.10);
}

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

body {
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ========== LOGIN ========== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1A237E 0%, #1565C0 50%, #0288D1 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 18px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo i {
  font-size: 52px;
  color: var(--primary);
  display: block;
  margin-bottom: 10px;
}

.login-logo h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: 2px;
}

.login-logo p {
  color: var(--text-light);
  font-size: 13px;
  margin-top: 4px;
}

.login-form .form-group {
  margin-bottom: 18px;
}

.login-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-light);
  font-size: 13px;
}

.login-form input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.2s;
  outline: none;
}

.login-form input:focus {
  border-color: var(--primary);
}

.btn-login {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.btn-login:hover { background: var(--primary-dark); }
.btn-login:active { transform: scale(0.98); }

.login-error {
  background: #FFEBEE;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
}

/* ========== APP LAYOUT ========== */
.app-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ========== HEADER ========== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 12px;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  gap: 10px;
}

.menu-btn {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.menu-btn:hover { background: rgba(255,255,255,0.15); }

.header-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.mobile-top-icons {
  display: none;
  flex: 1;
  overflow-x: auto;
  gap: 4px;
  align-items: center;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.mobile-top-icons::-webkit-scrollbar { display: none; }

.mobile-top-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 52px;
  flex-shrink: 0;
  transition: background 0.2s;
}

.mobile-top-btn i { font-size: 16px; }
.mobile-top-btn.active { background: rgba(255,255,255,0.35); }
.mobile-top-btn:hover { background: rgba(255,255,255,0.25); }

.header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  flex-shrink: 0;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  top: 0; left: -260px;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  z-index: 200;
  transition: left 0.3s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  box-shadow: 3px 0 20px rgba(0,0,0,0.25);
}

.sidebar.open { left: 0; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 190;
}

.sidebar-overlay.show { display: block; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  background: rgba(0,0,0,0.2);
  color: white;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
}

.sidebar-header i { font-size: 22px; }
.sidebar-title { flex: 1; }

.sidebar-close {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0.7;
}

.sidebar-close:hover { opacity: 1; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 15px;
  transition: background 0.2s;
  border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.12);
  border-left-color: #64B5F6;
}

.nav-item i { width: 22px; font-size: 17px; opacity: 0.85; }

.nav-item-danger { color: #EF9A9A; }
.nav-item-danger:hover { background: rgba(244,67,54,0.15); border-left-color: #EF9A9A; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 8px 16px;
}

/* ========== CONTENT ========== */
.app-content {
  margin-top: var(--header-h);
  flex: 1;
  padding: 20px;
  max-width: 1200px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.section { display: none; }
.section.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ========== HOME ========== */
.home-welcome {
  text-align: center;
  padding: 40px 20px;
}

.home-icon {
  font-size: 72px;
  color: var(--primary);
  margin-bottom: 16px;
}

.home-welcome h2 {
  font-size: 28px;
  color: var(--primary-dark);
  font-weight: 800;
}

.home-welcome p {
  color: var(--text-light);
  font-size: 15px;
  margin-top: 8px;
}

.home-subtitle { margin-top: 24px !important; }

.home-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 32px;
}

.home-card {
  background: white;
  border-radius: var(--radius);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  min-width: 130px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
}

.home-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(21,101,192,0.2);
  border-color: var(--primary-light);
}

.home-card i {
  font-size: 36px;
  color: var(--primary);
}

.home-card span {
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
}

/* ========== CARDS & FORMS ========== */
.form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
}

.form-group {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group-wide {
  flex: 100%;
}

.form-group label {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,101,192,0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* ========== BUTTONS ========== */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.web-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-btn-group {
  display: none;
  margin-top: 12px;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #1B5E20; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #BF360C; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #B71C1C; }

.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #37474F; }

.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #01579B; }

.btn-block { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }

.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 6px; }

/* ========== AMBIENTES GRID ========== */
.ambientes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.ambiente-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: all 0.2s;
  position: relative;
}

.ambiente-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(21,101,192,0.18);
}

.ambiente-card.active { border-color: var(--primary); background: #E3F2FD; }

.ambiente-card i {
  font-size: 32px;
  color: var(--primary);
}

.ambiente-card span {
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.ambiente-badge {
  position: absolute;
  top: 6px; right: 6px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ========== AMBIENTE FORM ========== */
.ambiente-form {
  border: 2px solid var(--primary-light);
}

.ambiente-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.ambiente-form-header h3 {
  font-size: 18px;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ambiente-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ambiente-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--primary);
  background: white;
  color: var(--primary);
  transition: all 0.2s;
}

.ambiente-tab.active {
  background: var(--primary);
  color: white;
}

/* ========== OBS + MIC ========== */
.obs-group {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.obs-group textarea {
  flex: 1;
}

.btn-mic {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-mic:hover { background: var(--primary-dark); }
.btn-mic.recording {
  background: var(--danger);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

/* ========== FOTOS ========== */
.foto-area {
  background: #F5F5F5;
  border-radius: 8px;
  padding: 12px;
}

.foto-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.fotos-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.foto-item {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.foto-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.foto-delete {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(198,40,40,0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== SIGNATURE ========== */
.signature-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #FAFAFA;
}

.signature-canvas {
  display: block;
  width: 100%;
  height: 200px;
  background: white;
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none;
}

.signature-btns {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.signature-hint {
  font-size: 12px;
  color: var(--text-light);
  font-style: italic;
}

/* ========== TABLES ========== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: white;
  padding: 16px;
  margin-bottom: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--primary);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #ECEFF1;
  vertical-align: middle;
}

.data-table tr:hover td { background: #F5F7FA; }

.data-table tr:last-child td { border-bottom: none; }

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #323232;
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }

/* ========== ASSINATURAS LIST ========== */
.ass-item {
  background: #F8F9FA;
  border-radius: 8px;
  padding: 14px 16px;
  border-left: 4px solid var(--primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ass-item-info { flex: 1; }
.ass-item-img img {
  height: 60px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: white;
}

/* ========================================================
   RESPONSIVO - MOBILE (≤768px)
   ======================================================== */
@media (max-width: 768px) {
  :root { --header-h: 100px; }

  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 10px;
    gap: 6px;
  }

  .header-title { font-size: 17px; }

  .mobile-top-icons {
    display: flex;
    width: 100%;
    flex-basis: 100%;
    padding-bottom: 4px;
  }

  .header-user { font-size: 12px; }

  .app-content {
    margin-top: calc(var(--header-h) + 8px);
    padding: 12px;
  }

  .web-btn-group { display: none !important; }
  .mobile-btn-group { display: block !important; }

  .form-group { min-width: 100%; }

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

  .ambiente-card {
    padding: 14px 8px;
  }

  .ambiente-card i { font-size: 26px; }
  .ambiente-card span { font-size: 11px; }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .home-cards { gap: 10px; }
  .home-card { min-width: 100px; padding: 20px 12px; }
  .home-card i { font-size: 28px; }

  .ambiente-form-header { flex-direction: column; align-items: flex-start; }

  .signature-canvas { height: 160px; }

  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 8px; }

  .btn { padding: 10px 14px; font-size: 12px; }
}

@media (max-width: 480px) {
  .ambientes-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .home-cards {
    grid-template-columns: repeat(2, 1fr);
    display: grid;
  }
}

/* ========== WEB (>768px) - SIDEBAR SEMPRE VISÍVEL OPCIONALMENTE ========== */
@media (min-width: 1024px) {
  .app-content {
    padding: 24px 32px;
  }
}
