/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f5f5f7;
  color: #1c1c1e;
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== LOGIN ===== */
.login-body {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh; padding: 1rem;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 2rem;
  width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}
.login-logo { font-size: 3rem; margin-bottom: 0.5rem; }
.login-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; color: #333; }
.login-sub { color: #666; margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-card label {
  display: block; text-align: left; margin: 0.75rem 0 0.25rem;
  font-size: 0.85rem; font-weight: 600; color: #444;
}
.login-card input {
  width: 100%; padding: 0.75rem 1rem; border: 1px solid #ddd;
  border-radius: 10px; font-size: 1rem; transition: border-color 0.2s;
}
.login-card input:focus { outline: none; border-color: #667eea; }
.error-msg { color: #e74c3c; font-size: 0.85rem; margin-top: 0.75rem; min-height: 1.2em; }

/* ===== BOTÕES ===== */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .btn-print, .btn-excel, .btn-upload {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1.2rem; border: none; border-radius: 10px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: #667eea; color: #fff; }
.btn-primary:hover { background: #5568d3; transform: translateY(-1px); }
.btn-secondary { background: #e9e9eb; color: #333; }
.btn-secondary:hover { background: #ddd; }
.btn-danger { background: #ff3b30; color: #fff; }
.btn-danger:hover { background: #d70015; }
.btn-ghost { background: transparent; color: #667eea; border: 1px solid #667eea; }
.btn-print { background: #34c759; color: #fff; }
.btn-excel { background: #217346; color: #fff; }
.btn-upload { background: #5856d6; color: #fff; }

/* ===== LAYOUT APP ===== */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: 320px; background: #fff; border-right: 1px solid #e5e5ea;
  display: flex; flex-direction: column; position: fixed; height: 100vh;
  z-index: 10; transition: transform 0.3s;
}
#sidebar.hidden-mobile { transform: translateX(-100%); }
#main { flex: 1; margin-left: 320px; min-height: 100vh; }

.sidebar-header {
  padding: 1rem; border-bottom: 1px solid #e5e5ea;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.sidebar-header h2 { font-size: 1.1rem; color: #333; }
.sidebar-search { padding: 0.75rem 1rem; border-bottom: 1px solid #e5e5ea; }
.sidebar-search input {
  width: 100%; padding: 0.6rem 0.9rem; border: 1px solid #ddd;
  border-radius: 10px; font-size: 0.9rem;
}
.client-list { flex: 1; overflow-y: auto; }
.client-item {
  padding: 0.9rem 1rem; border-bottom: 1px solid #f0f0f0;
  cursor: pointer; transition: background 0.15s;
}
.client-item:hover, .client-item.active { background: #f2f2f7; }
.client-item-name { font-weight: 600; font-size: 0.95rem; color: #1c1c1e; }
.client-item-info { font-size: 0.8rem; color: #8e8e93; margin-top: 0.15rem; }

/* ===== HEADER ===== */
.topbar {
  background: #fff; border-bottom: 1px solid #e5e5ea;
  padding: 0.75rem 1.25rem; display: flex; align-items: center;
  justify-content: space-between; gap: 0.75rem; position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: #333; }
.topbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===== FORMULÁRIO ===== */
.form-container { padding: 1.25rem; max-width: 900px; margin: 0 auto; }
.form-section {
  background: #fff; border-radius: 14px; padding: 1.25rem;
  margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.form-section h3 {
  font-size: 1rem; color: #667eea; margin-bottom: 1rem;
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 2px solid #f2f2f7; padding-bottom: 0.5rem;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.form-group { display: flex; flex-direction: column; }
.form-group label {
  font-size: 0.8rem; font-weight: 600; color: #555; margin-bottom: 0.35rem;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
  padding: 0.6rem 0.8rem; border: 1px solid #ddd; border-radius: 10px;
  font-size: 0.95rem; font-family: inherit; background: #fafafa;
  transition: border-color 0.2s, background 0.2s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: #667eea; background: #fff;
}
.form-group textarea { resize: vertical; min-height: 80px; }

.checkbox-row {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem;
}
.checkbox-row input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: #667eea; cursor: pointer;
}
.checkbox-row label { font-size: 0.9rem; color: #333; cursor: pointer; }

.obs-input {
  margin-left: 1.6rem; margin-bottom: 0.75rem;
  font-size: 0.85rem; color: #555; font-style: italic;
}

/* ===== UPLOAD DE FOTOS/VÍDEOS ===== */
.upload-zone {
  border: 2px dashed #ccc; border-radius: 12px; padding: 1.5rem;
  text-align: center; cursor: pointer; transition: all 0.2s;
  background: #fafafa; margin-bottom: 0.75rem;
}
.upload-zone:hover { border-color: #667eea; background: #f0f0ff; }
.upload-zone-text { color: #666; font-size: 0.9rem; }
.upload-zone-text strong { color: #667eea; }
.upload-input { display: none; }

.media-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem; margin-top: 0.75rem;
}
.media-item {
  position: relative; border-radius: 10px; overflow: hidden;
  background: #000; aspect-ratio: 1;
}
.media-item img, .media-item video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.media-item video { object-fit: contain; }
.media-item-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); opacity: 0; transition: opacity 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.media-item:hover .media-item-overlay { opacity: 1; }
.media-item-btn {
  background: #fff; border: none; border-radius: 50%;
  width: 32px; height: 32px; cursor: pointer; font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
}
.media-badge {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 0.7rem;
  padding: 2px 6px; border-radius: 4px;
}

/* ===== EVOLUÇÕES ===== */
.evolution-card {
  background: #f9f9fb; border-radius: 10px; padding: 0.9rem;
  margin-bottom: 0.6rem; border-left: 3px solid #667eea;
}
.evolution-card-header { display: flex; justify-content: space-between; align-items: center; }
.evolution-card-title { font-weight: 600; font-size: 0.9rem; }
.evolution-card-date { font-size: 0.75rem; color: #8e8e93; }
.evolution-card-body { font-size: 0.9rem; color: #444; margin-top: 0.4rem; }

/* ===== EMPTY STATES ===== */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: #8e8e93;
}
.empty-state-icon { font-size: 3rem; margin-bottom: 0.5rem; }

/* ===== PRINT / PDF ===== */
@media print {
  body { background: #fff; }
  #sidebar, .topbar, .no-print { display: none !important; }
  #main { margin-left: 0 !important; }
  .form-container { max-width: 100%; padding: 0; }
  .form-section {
    box-shadow: none; border: 1px solid #ddd; border-radius: 0;
    margin-bottom: 1rem; page-break-inside: avoid;
  }
  .btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .btn-print, .btn-excel, .btn-upload {
    display: none !important;
  }
  input, textarea, select {
    border: none !important; background: transparent !important;
    padding-left: 0 !important;
  }
  .form-group label { color: #333; font-weight: 700; }
  .media-gallery { grid-template-columns: repeat(4, 1fr); }
  .media-item { aspect-ratio: auto; height: 150px; }
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  #sidebar { width: 100%; }
  #main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .topbar-title { font-size: 1rem; }
  .btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .btn-print, .btn-excel, .btn-upload {
    padding: 0.55rem 0.9rem; font-size: 0.85rem;
  }
  .login-card { padding: 1.5rem; }
  .media-gallery { grid-template-columns: repeat(3, 1fr); }
}

/* ===== UTILITÁRIOS ===== */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
