/* =========================================================
   Agenda de Contatos Estratégicos — Estilos customizados
   Complementa Tailwind CDN
   ========================================================= */

/* Scroll suave */
html {
  scroll-behavior: smooth;
}

/* Esconder scrollbar em Chrome/Safari mas manter funcionalidade */
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Transição suave de opacidade para toasts */
#toasts > div {
  transition: opacity 0.35s ease;
  pointer-events: auto;
}

/* Badge hover */
.badge-hover:hover {
  filter: brightness(0.95);
  cursor: pointer;
}

/* Input focus ring customizado */
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #475569;
  box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.1);
}

/* Botão ativo nav */
[data-nav].active {
  color: #0f172a;
}

/* Card hover sutil */
.card-hover:hover {
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Loading spinner */
.spinner {
  border: 3px solid #e2e8f0;
  border-top: 3px solid #0f172a;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Share popup */
.share-popup {
  animation: sharePopupIn 0.15s ease-out;
}

@keyframes sharePopupIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.share-btn:hover {
  transform: scale(1.1);
}

/* Avatar circular */
.contact-avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.contact-avatar-placeholder {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Upload de foto no formulário */
.photo-upload-area {
  position: relative;
  cursor: pointer;
  display: inline-block;
}

.photo-upload-area:hover .photo-upload-overlay {
  opacity: 1;
}

.photo-upload-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* =========================================================
   Image Crop Modal
   ========================================================= */

.crop-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: cropFadeIn 0.2s ease-out;
}

@keyframes cropFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.crop-viewport {
  position: relative;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.8);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.crop-viewport:active {
  cursor: grabbing;
}

.crop-viewport img {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  pointer-events: none;
  -webkit-user-drag: none;
  max-width: none;
}

.crop-instruction {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  margin-top: 1rem;
  text-align: center;
}

.crop-zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  outline: none;
  margin-top: 1rem;
}

.crop-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.crop-zoom-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.crop-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.crop-btn {
  padding: 0.6rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.crop-btn:hover { opacity: 0.85; }

.crop-btn-confirm {
  background: #0f172a;
  color: white;
}

.crop-btn-cancel {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

@media (max-width: 360px) {
  .crop-viewport {
    width: 240px;
    height: 240px;
  }
}

/* =========================================================
   Login Page
   ========================================================= */

.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-card input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

/* =========================================================
   User Dropdown
   ========================================================= */

.user-dropdown {
  animation: dropdownIn 0.15s ease-out;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Admin Tables
   ========================================================= */

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #64748b;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid #e2e8f0;
}

.admin-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: #f8fafc;
}

/* Permission checkbox grid */
.perm-group {
  margin-bottom: 1rem;
}

.perm-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.25rem;
}

.perm-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.8rem;
  color: #334155;
}

.perm-item input[type="checkbox"] {
  accent-color: #3b82f6;
}

/* =========================================================
   Mobile Bottom Navigation
   ========================================================= */

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.06);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 6px 0 4px;
  font-size: 0.65rem;
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  border: none;
  background: none;
  cursor: pointer;
}

.mobile-nav-item.active {
  color: #0f172a;
}

.mobile-nav-item:hover {
  color: #475569;
}

.mobile-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 2px;
}

.mobile-nav-label {
  font-weight: 500;
  line-height: 1;
}

/* =========================================================
   Mobile "More" Bottom Sheet
   ========================================================= */

.mobile-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.mobile-sheet-overlay.hidden {
  display: none;
}

.mobile-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mobile-sheet-overlay.open .mobile-sheet-backdrop {
  opacity: 1;
}

.mobile-sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 1rem 1rem 0 0;
  padding: 0.5rem 1rem 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
}

.mobile-sheet-overlay.open .mobile-sheet-content {
  transform: translateY(0);
}

.mobile-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #cbd5e1;
  margin: 0 auto 0.75rem;
}

.mobile-sheet-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  color: #475569;
  text-decoration: none;
  transition: background 0.15s ease;
}

.mobile-sheet-item:hover,
.mobile-sheet-item:active {
  background: #f1f5f9;
}

.mobile-sheet-item.active {
  color: #0f172a;
  background: #f1f5f9;
  font-weight: 600;
}

/* Responsividade extra para mobile */
@media (max-width: 640px) {
  .nav-fixed {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .login-card {
    padding: 1.5rem;
  }
}
