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

/* ============================================================
   PEEPCONNECT DESIGN SYSTEM — v1.0
   Fundação: Sofisticação & Confiança
   Grid: 4px
   Cor de destaque: #1F74FF (Azul Confiança)
   Profundidade: Bordas + sombras sutis
   ============================================================ */

:root {
  /* Cores base - Serão sobrescritas pelo Theme Engine */
  --pc-blue: #1F74FF;
  --pc-blue-hover: #1662E5;
  --pc-red: #E51E2A;
  --pc-red-hover: #D11925;
  --pc-white: #FFFFFF;
  --pc-black: #000000;
  --pc-dark-blue: #0C192C;
  --pc-success: #4ADE80;
  --pc-warning: #FBBF24;
  --pc-error: var(--pc-red);

  /* Hierarquia de texto */
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.72);
  --text-muted: rgba(255, 255, 255, 0.44);
  --text-faint: rgba(255, 255, 255, 0.24);

  /* Superfícies */
  --bg-page: #050505;
  --bg-surface: #111111;
  --bg-surface-light: #1A1A1A;

  /* Bordas */
  --border-default: rgba(255, 255, 255, 0.12);
  --border-muted: rgba(255, 255, 255, 0.05);

  /* Raios */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Grid de 4px */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Tipografia */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Profundidade */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.20);
  --pc-shadow: var(--shadow-md);

  /* Animação */
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  --duration: 150ms;

  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;
}


/* ===== RESET ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--pc-font, var(--font-sans));
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}


a[href^="tel"] {
  color: inherit !important;
  text-decoration: none !important;
}

/* ===== LAYOUT ===== */
.layout {
  display: flex;
  min-height: 100vh;
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main-content {
  padding: var(--space-8);
  width: 100%;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-page);
  border-right: 1px solid var(--border-muted);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  padding: var(--space-6) var(--space-4);
  transition: width var(--duration) var(--ease);
  z-index: 100;
  overflow-x: hidden;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-10);
  padding: 0 var(--space-2);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: var(--pc-blue);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  flex-shrink: 0;
  font-size: 13px;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.02em;
  transition: opacity var(--duration);
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-text {
  opacity: 0;
  pointer-events: none;
  width: 0;
}

/* ===== NAV ===== */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-4) var(--space-3) var(--space-2);
  transition: opacity var(--duration);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--duration) var(--ease);
  position: relative;
}

.nav-link i {
  font-size: 18px;
  flex-shrink: 0;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-link.active {
  background: rgba(31, 116, 255, 0.08);
  color: var(--pc-blue);
  font-weight: 600;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--pc-blue);
  border-radius: 0 3px 3px 0;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: var(--space-3) 0;
}

.sidebar.collapsed .nav-link.active::before {
  left: 0;
}

/* Toggle button */
.sidebar-toggle {
  position: absolute;
  bottom: var(--space-6);
  right: var(--space-4);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-surface-light);
  border: 1px solid var(--border-muted);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  font-size: 14px;
}

.sidebar.collapsed .sidebar-toggle {
  right: 50%;
  transform: translateX(50%);
}

.sidebar-toggle:hover {
  background: var(--pc-blue);
  color: white;
  border-color: var(--pc-blue);
}

/* ===== MOBILE SIDEBAR ===== */
.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-surface-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 20px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  z-index: 201;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ===== TOPBAR ===== */
.topbar {
  height: 56px;
  padding: 0 var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-page);
  position: sticky;
  top: 0;
  z-index: 90;
  gap: var(--space-4);
}

.search-container {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  padding: 8px var(--space-4) 8px 36px;
  border-radius: 20px;
  font-size: 13px;
  transition: all var(--duration) var(--ease);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.search-input:focus {
  border-color: var(--pc-blue);
  background: var(--bg-surface-light);
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 116, 255, 0.08);
}

.search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

.user-info-widget {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.login-info {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-3) 4px 4px;
  background: var(--bg-surface);
  border-radius: 32px;
  border: 1px solid var(--border-muted);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.user-badge:hover {
  background: var(--bg-surface-light);
  border-color: var(--border-default);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--pc-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}

.username {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ===== TYPOGRAPHY ===== */
h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 14px;
  font-weight: 600;
}

/* ===== TABLES ===== */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-muted);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-muted);
  font-size: 13px;
  color: var(--text-secondary);
}

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

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ===== BUTTONS ===== */
.btn {
  font-family: inherit;
  font-weight: 600;
  transition: all var(--duration) var(--ease);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: none;
  border-radius: var(--radius-md);
  padding: 0 var(--space-5);
  height: 36px;
  font-size: 13px;
}

.btn-primary {
  background: var(--pc-blue);
  color: white;
}

.btn-primary:hover {
  background: var(--pc-blue-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-muted);
}

.btn-secondary:hover {
  background: var(--bg-surface-light);
  color: var(--text-primary);
}

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

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-muted);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  background: transparent;
  text-decoration: none;
  font-size: 14px;
}

.action-btn:hover {
  border-color: var(--pc-blue);
  color: var(--pc-blue);
  background: rgba(31, 116, 255, 0.05);
}

/* ===== BADGES ===== */
.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}

.badge-success {
  background: rgba(74, 222, 128, 0.10);
  color: #4ADE80;
}

.badge-warning {
  background: rgba(251, 191, 36, 0.10);
  color: #FBBF24;
}

.badge-error {
  background: rgba(239, 68, 68, 0.10);
  color: #EF4444;
}

/* ===== FORM ELEMENTS ===== */
input,
select,
textarea {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-surface-light);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 8px var(--space-3);
  font-size: 13px;
  width: 100%;
  transition: all var(--duration) var(--ease);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--pc-blue);
  box-shadow: 0 0 0 3px rgba(31, 116, 255, 0.08);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
  padding: var(--space-4);
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  padding: var(--space-6);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 200ms var(--ease);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== FORM SECTIONS ===== */
.form-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.section-header {
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-muted);
  padding-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.section-header i {
  font-size: 20px;
  color: var(--pc-blue);
}

.section-header h3 {
  font-size: 14px;
  margin: 0;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.input-group label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== TEMPLATE CARDS ===== */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
}

.template-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--duration) var(--ease);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.template-card:hover {
  border-color: var(--border-default);
  transform: translateY(-1px);
}

.template-type {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(31, 116, 255, 0.08);
  color: var(--pc-blue);
  width: fit-content;
}

.template-body {
  background: var(--bg-surface-light);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* ===== ICON GALLERY ===== */
.icon-gallery {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-2);
  max-height: 148px;
  overflow-y: auto;
  background: var(--bg-surface-light);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  margin-top: var(--space-2);
}

.icon-option {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  transition: all var(--duration) var(--ease);
}

.icon-option:hover,
.icon-option.active {
  background: var(--pc-blue);
  color: white;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ===== STAT CARD (generic) ===== */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--duration) var(--ease);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: var(--border-default);
}

/* ===== GRIDS ===== */
.responsive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-surface-light);
  border-radius: 8px;
}

/* Removed non-standard ::-webkit-scrollbar-thumb:hover to resolve browser parsing warning */

/* ===== ANIMATION ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-transition {
  animation: fadeIn 300ms var(--ease);
}

/* ============================================================
   RESPONSIVE — MOBILE BREAKPOINTS
   ============================================================ */

/* Tablet (≤1024px) */
@media (max-width: 1024px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar .sidebar-title,
  .sidebar .nav-label,
  .sidebar .nav-text {
    opacity: 0;
    pointer-events: none;
    width: 0;
  }

  .sidebar .nav-link {
    justify-content: center;
    padding: var(--space-3) 0;
  }

  .sidebar .nav-link.active::before {
    left: 0;
  }

  .sidebar .sidebar-toggle {
    right: 50%;
    transform: translateX(50%);
  }

  .main-content {
    padding: var(--space-6);
  }

  .topbar {
    padding: 0 var(--space-6);
  }
}

/* Mobile (≤768px) */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 240px !important;
    height: 100vh;
    z-index: 200;
    transition: left 250ms var(--ease);
    box-shadow: none;
  }

  .sidebar.mobile-open {
    left: 0;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
  }

  .sidebar.mobile-open .sidebar-title,
  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .nav-text {
    opacity: 1 !important;
    pointer-events: auto !important;
    width: auto !important;
  }

  .sidebar.mobile-open .nav-link {
    justify-content: flex-start !important;
    padding: var(--space-2) var(--space-3) !important;
  }

  .sidebar.mobile-open .nav-link.active::before {
    left: -16px !important;
  }

  .sidebar-toggle {
    display: none !important;
  }

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

  .mobile-menu-btn {
    display: flex;
  }

  .topbar {
    padding: 0 var(--space-4);
    height: 52px;
    gap: var(--space-2);
  }

  .search-container {
    max-width: none;
  }

  .search-input {
    padding: 8px var(--space-3) 8px 32px;
    font-size: 12px;
  }

  .search-icon {
    left: 10px;
    font-size: 14px;
  }

  .login-info {
    display: none;
  }

  .username {
    display: none;
  }

  .user-badge {
    padding: 4px;
    gap: 0;
  }

  .main-content {
    padding: var(--space-4);
  }

  .layout {
    flex-direction: column;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
  }

  .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  h1 {
    font-size: 20px !important;
  }

  .responsive-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-3);
  }

  .table-container {
    margin: 0 calc(var(--space-4) * -1);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .template-grid {
    grid-template-columns: 1fr;
  }

  .template-card {
    padding: var(--space-4);
  }

  .modal-overlay {
    padding: var(--space-2);
    align-items: flex-end;
  }

  .modal-content {
    max-width: 100%;
    padding: var(--space-5);
    max-height: 85vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .form-section {
    padding: var(--space-5);
  }

  .icon-gallery {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Small phones (≤480px) */
@media (max-width: 480px) {
  .main-content {
    padding: var(--space-3);
  }

  .topbar {
    padding: 0 var(--space-3);
  }

  h1 {
    font-size: 18px !important;
  }

  .btn {
    padding: 0 var(--space-4);
    font-size: 12px;
    height: 32px;
  }

  td,
  th {
    padding: 8px var(--space-3);
    font-size: 12px;
  }
}