/*
 * ═══════════════════════════════════════════════════════════════
 *  CWDesk Portal — Design System
 *  suporte.cwsoftware.com.br
 *
 *  Fontes: Outfit (já carregada em App.razor) + DM Sans
 *  Ícones: Font Awesome 6 (já carregado em App.razor)
 *  Estilo: Precision Dark — fundo profundo, acentos azul-índigo,
 *          bordas sutis, blur nos cards, tipografia limpa.
 *
 *  Regras de uso:
 *  - SEMPRE use as CSS variables abaixo. Nunca hardcode cores.
 *  - Classes de componente (.pd-card, .pd-btn-*, etc.) são reutilizáveis.
 *  - Para telas com layout próprio (ex: login), use BlankLayout +
 *    background cw-bg-root e os mesmos tokens.
 *  - Não adicione Tailwind utilities que não existam no purge; prefira
 *    classes .pd-* ou estilos inline com os tokens.
 * ═══════════════════════════════════════════════════════════════
 */

/* ── Google Font (DM Sans — complementar ao Outfit) ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500&display=swap');

/* ════════════════════════════════
   1. TOKENS / VARIÁVEIS GLOBAIS
   ════════════════════════════════ */
:root {
  /* Background layers */
  --pd-bg:          #080d1a;      /* fundo mais profundo (telas blank) */
  --pd-bg-app:      #0c1120;      /* fundo do app autenticado          */
  --pd-sidebar:     #0a0f1e;      /* sidebar                           */
  --pd-surface:     rgba(12,18,37,0.78); /* cards / painéis            */
  --pd-surface-2:   rgba(15,23,42,0.6);  /* superfície secundária       */

  /* Borders */
  --pd-border:      rgba(255,255,255,0.07);
  --pd-border-hi:   rgba(99,130,255,0.5);
  --pd-border-card: rgba(91,130,255,0.15);

  /* Accent — azul-índigo elétrico */
  --pd-accent:      #5b82ff;
  --pd-accent-2:    #7f5af0;
  --pd-accent-glow: rgba(91,130,255,0.18);

  /* Text */
  --pd-text:        #e8edf8;
  --pd-text-2:      #94a3b8;
  --pd-text-3:      #4a5578;
  --pd-muted:       #2e3655;

  /* Status */
  --pd-success:     #22c55e;
  --pd-success-bg:  rgba(34,197,94,0.08);
  --pd-warning:     #f59e0b;
  --pd-warning-bg:  rgba(245,158,11,0.08);
  --pd-error:       #ff6b6b;
  --pd-error-bg:    rgba(255,107,107,0.08);
  --pd-info:        #38bdf8;
  --pd-info-bg:     rgba(56,189,248,0.08);

  /* Ticket status */
  --pd-status-open:       #38bdf8;
  --pd-status-open-bg:    rgba(56,189,248,0.1);
  --pd-status-progress:   #f59e0b;
  --pd-status-progress-bg:rgba(245,158,11,0.1);
  --pd-status-resolved:   #22c55e;
  --pd-status-resolved-bg:rgba(34,197,94,0.1);
  --pd-status-closed:     #64748b;
  --pd-status-closed-bg:  rgba(100,116,139,0.12);

  /* Typography */
  --pd-ff-head: 'Outfit', sans-serif;
  --pd-ff-body: 'DM Sans', 'Outfit', sans-serif;

  /* Radius */
  --pd-radius-sm:  8px;
  --pd-radius:     12px;
  --pd-radius-lg:  16px;
  --pd-radius-xl:  20px;

  /* Shadows */
  --pd-shadow-card: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03);
  --pd-shadow-btn:  0 4px 24px rgba(91,130,255,0.38);
  --pd-shadow-glow: 0 0 0 3px var(--pd-accent-glow);
}


/* ════════════════════════════════
   2. BASE DO PORTAL
   ════════════════════════════════ */
.pd-app {
  min-height: 100vh;
  background-color: var(--pd-bg-app);
  font-family: var(--pd-ff-body);
  color: var(--pd-text);
}

/* Tela blank (login, etc.) */
.pd-blank {
  min-height: 100vh;
  background-color: var(--pd-bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(91,130,255,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(127,90,240,0.07) 0%, transparent 70%);
  font-family: var(--pd-ff-body);
  color: var(--pd-text);
}

/* Dot-grid decorativo (adicionar como ::before no wrapper) */
.pd-dot-grid::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(99,130,255,0.15) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 20%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 20%, transparent 100%);
  pointer-events: none;
  z-index: 0;
  animation: pd-grid-drift 20s ease-in-out infinite alternate;
}
@keyframes pd-grid-drift {
  from { transform: translate(0, 0); }
  to   { transform: translate(8px, 8px); }
}


/* ════════════════════════════════
   3. SIDEBAR
   ════════════════════════════════ */
.pd-sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--pd-sidebar);
  border-right: 1px solid var(--pd-border);
  min-height: 100vh;
}

.pd-sidebar-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--pd-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pd-sidebar-logo {
  width: 2.25rem; height: 2.25rem;
  border-radius: var(--pd-radius-sm);
  background: rgba(91,130,255,0.12);
  border: 1px solid var(--pd-border-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--pd-accent);
  flex-shrink: 0;
  overflow: hidden;
}
.pd-sidebar-logo img { width: 100%; height: 100%; object-fit: cover; }

.pd-sidebar-company-name {
  font-family: var(--pd-ff-head);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--pd-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pd-sidebar-company-sub {
  font-size: 0.68rem;
  color: var(--pd-text-3);
  margin-top: 0.1rem;
}

.pd-nav-section {
  padding: 1rem 0.75rem 0.5rem;
}
.pd-nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pd-text-3);
  padding: 0 0.5rem;
  margin-bottom: 0.35rem;
  display: block;
}
.pd-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--pd-radius-sm);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--pd-text-3);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 1px;
}
.pd-nav-link i { width: 1rem; text-align: center; font-size: 0.8rem; }
.pd-nav-link:hover {
  background: rgba(255,255,255,0.04);
  color: var(--pd-text-2);
}
.pd-nav-link.active {
  background: rgba(91,130,255,0.12);
  color: var(--pd-text);
  border: 1px solid rgba(91,130,255,0.2);
}
.pd-nav-link.active i { color: var(--pd-accent); }

.pd-sidebar-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--pd-border);
  margin-top: auto;
}


/* ════════════════════════════════
   4. MAIN CONTENT AREA
   ════════════════════════════════ */
.pd-main {
  flex: 1;
  min-width: 0;
  overflow: auto;
}
.pd-content {
  padding: 2rem 2.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

/* Page header */
.pd-page-header {
  margin-bottom: 1.75rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.pd-page-title {
  font-family: var(--pd-ff-head);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--pd-text);
  letter-spacing: -0.02em;
  margin: 0;
}
.pd-page-sub {
  font-size: 0.82rem;
  color: var(--pd-text-3);
  margin: 0.25rem 0 0;
}


/* ════════════════════════════════
   5. CARDS
   ════════════════════════════════ */
.pd-card {
  background: var(--pd-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--pd-border-card);
  border-radius: var(--pd-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--pd-shadow-card);
  position: relative;
  overflow: hidden;
}

/* linha de acento no topo */
.pd-card-accent::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--pd-accent), transparent);
  opacity: 0.6;
}

.pd-card-sm  { padding: 1rem 1.25rem; }
.pd-card-lg  { padding: 2rem 2.25rem; }


/* ════════════════════════════════
   6. STAT / METRIC CARDS
   ════════════════════════════════ */
.pd-stat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.pd-stat-value {
  font-family: var(--pd-ff-head);
  font-size: 2rem;
  font-weight: 700;
  color: var(--pd-text);
  letter-spacing: -0.03em;
  line-height: 1;
}
.pd-stat-label {
  font-size: 0.78rem;
  color: var(--pd-text-3);
  font-weight: 500;
}
.pd-stat-icon {
  width: 2.5rem; height: 2.5rem;
  border-radius: var(--pd-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  background: rgba(91,130,255,0.1);
  border: 1px solid rgba(91,130,255,0.2);
  color: var(--pd-accent);
}


/* ════════════════════════════════
   7. BOTÕES
   ════════════════════════════════ */
.pd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--pd-radius-sm);
  font-family: var(--pd-ff-head);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, box-shadow 0.15s, transform 0.12s;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.pd-btn:hover { transform: translateY(-1px); }
.pd-btn:active { transform: translateY(0); }

/* Shimmer interno */
.pd-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: skewX(-20deg);
  transition: left 0.45s ease;
}
.pd-btn:hover::after { left: 160%; }

.pd-btn-primary {
  background: linear-gradient(135deg, #4a6ff0 0%, #6a3fe8 100%);
  color: #fff;
  box-shadow: var(--pd-shadow-btn);
}
.pd-btn-primary:hover { box-shadow: 0 6px 32px rgba(74,111,240,0.55); opacity: 0.92; }

.pd-btn-secondary {
  background: rgba(91,130,255,0.1);
  border: 1px solid rgba(91,130,255,0.25);
  color: #8ba6ff;
}
.pd-btn-secondary:hover { background: rgba(91,130,255,0.16); color: var(--pd-text); }

.pd-btn-ghost {
  background: transparent;
  color: var(--pd-text-3);
}
.pd-btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--pd-text-2); }

.pd-btn-danger {
  background: rgba(255,107,107,0.1);
  border: 1px solid rgba(255,107,107,0.25);
  color: #ff9a9a;
}
.pd-btn-danger:hover { background: rgba(255,107,107,0.18); }

.pd-btn-sm { padding: 0.4rem 0.75rem; font-size: 0.78rem; }
.pd-btn-lg { padding: 0.8rem 1.5rem; font-size: 0.95rem; }
.pd-btn-full { width: 100%; }
.pd-btn-icon { padding: 0.6rem; }


/* ════════════════════════════════
   8. INPUTS / FORMULÁRIOS
   ════════════════════════════════ */
.pd-field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.pd-field:last-child { margin-bottom: 0; }

.pd-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--pd-text-2);
  letter-spacing: 0.02em;
}

.pd-input-wrap { position: relative; }
.pd-input-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--pd-text-3);
  font-size: 0.78rem;
  pointer-events: none;
  transition: color 0.15s;
}
.pd-input-wrap:focus-within .pd-input-icon { color: var(--pd-accent); }

.pd-input-action {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--pd-text-3);
  background: none;
  border: none;
  padding: 0.2rem;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  transition: color 0.15s;
}
.pd-input-action:hover { color: var(--pd-text-2); }

.pd-input,
.pd-select,
.pd-textarea {
  width: 100%;
  padding: 0.68rem 1rem;
  background: rgba(8, 13, 26, 0.85);
  border: 1px solid var(--pd-muted);
  border-radius: var(--pd-radius-sm);
  color: var(--pd-text);
  font-family: var(--pd-ff-body);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  box-sizing: border-box;
}
.pd-input.has-icon  { padding-left: 2.35rem; }
.pd-input.has-action{ padding-right: 2.35rem; }
.pd-input::placeholder,
.pd-textarea::placeholder { color: var(--pd-muted); }
.pd-input:focus,
.pd-select:focus,
.pd-textarea:focus {
  border-color: var(--pd-border-hi);
  background: rgba(12, 18, 40, 0.95);
  box-shadow: var(--pd-shadow-glow);
}

.pd-textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
.pd-select { appearance: none; cursor: pointer; }


/* ════════════════════════════════
   9. BADGES / STATUS PILLS
   ════════════════════════════════ */
.pd-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pd-badge-accent  { background: rgba(91,130,255,0.12); border:1px solid rgba(91,130,255,0.25); color:#8ba6ff; }
.pd-badge-success { background: var(--pd-success-bg); border:1px solid rgba(34,197,94,0.25);  color:#4ade80; }
.pd-badge-warning { background: var(--pd-warning-bg); border:1px solid rgba(245,158,11,0.25); color:#fbbf24; }
.pd-badge-error   { background: var(--pd-error-bg);   border:1px solid rgba(255,107,107,0.25);color:#f87171; }
.pd-badge-info    { background: var(--pd-info-bg);    border:1px solid rgba(56,189,248,0.25); color:#7dd3fc; }
.pd-badge-muted   { background: rgba(100,116,139,0.1);border:1px solid rgba(100,116,139,0.2);color:#64748b; }

/* Status de tickets */
.pd-badge-open     { background: var(--pd-status-open-bg);     border:1px solid rgba(56,189,248,0.25);  color: var(--pd-status-open); }
.pd-badge-progress { background: var(--pd-status-progress-bg); border:1px solid rgba(245,158,11,0.25);  color: var(--pd-status-progress); }
.pd-badge-resolved { background: var(--pd-status-resolved-bg); border:1px solid rgba(34,197,94,0.25);   color: var(--pd-status-resolved); }
.pd-badge-closed   { background: var(--pd-status-closed-bg);   border:1px solid rgba(100,116,139,0.2);  color: var(--pd-status-closed); }


/* ════════════════════════════════
   10. ALERTAS / MENSAGENS
   ════════════════════════════════ */
.pd-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 1rem;
  border-radius: var(--pd-radius-sm);
  font-size: 0.82rem;
  line-height: 1.5;
}
.pd-alert i { margin-top: 1px; flex-shrink: 0; }
.pd-alert-error   { background: var(--pd-error-bg);   border:1px solid rgba(255,107,107,0.25); color:#f87171; animation: pd-shake 0.35s cubic-bezier(.36,.07,.19,.97); }
.pd-alert-success { background: var(--pd-success-bg); border:1px solid rgba(34,197,94,0.25);  color:#4ade80; }
.pd-alert-warning { background: var(--pd-warning-bg); border:1px solid rgba(245,158,11,0.25); color:#fbbf24; }
.pd-alert-info    { background: var(--pd-info-bg);    border:1px solid rgba(56,189,248,0.25); color:#7dd3fc; }

@keyframes pd-shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}


/* ════════════════════════════════
   11. TABELAS
   ════════════════════════════════ */
.pd-table-wrap { overflow-x: auto; }
.pd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.pd-table th {
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pd-text-3);
  border-bottom: 1px solid var(--pd-border);
}
.pd-table td {
  padding: 0.85rem 1rem;
  color: var(--pd-text-2);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.pd-table tbody tr { transition: background 0.12s; }
.pd-table tbody tr:hover { background: rgba(91,130,255,0.04); }
.pd-table tbody tr:last-child td { border-bottom: none; }


/* ════════════════════════════════
   12. DIVISORES
   ════════════════════════════════ */
.pd-divider {
  border: none;
  border-top: 1px solid var(--pd-border);
  margin: 1.25rem 0;
}


/* ════════════════════════════════
   13. ANIMAÇÕES DE ENTRADA
   ════════════════════════════════ */
.pd-fade-up {
  animation: pd-fade-up 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.pd-fade-up-delay-1 { animation-delay: 0.05s; }
.pd-fade-up-delay-2 { animation-delay: 0.1s; }
.pd-fade-up-delay-3 { animation-delay: 0.15s; }
.pd-fade-up-delay-4 { animation-delay: 0.2s; }

@keyframes pd-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pd-fade-in {
  animation: pd-fade-in 0.3s ease both;
}
@keyframes pd-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* ════════════════════════════════
   14. UTILITIES ESPECÍFICAS DO PORTAL
   ════════════════════════════════ */
.pd-text-head { font-family: var(--pd-ff-head); }
.pd-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.pd-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.pd-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 768px) {
  .pd-grid-2, .pd-grid-3, .pd-grid-4 { grid-template-columns: 1fr; }
  .pd-content { padding: 1.25rem 1rem; }
}
@media (max-width: 1024px) {
  .pd-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .pd-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
