/* ==========================================================================
   TOOROCOLLAB — UI POLISH LAYER (loaded after main.css & portal.css)
   One font, one palette, consistent buttons/inputs/cards, accessible focus,
   no horizontal scroll, good tap targets. Works in day & night mode.
   ========================================================================== */

/* Theme tokens live in css/tokens.css */

/* One font family everywhere (except code/credential boxes) */
html, body, button, input, select, textarea { font-family: var(--font); }
body *:not(.tcn-cred):not(code):not(pre):not(kbd) { font-family: var(--font) !important; }
h1, h2, h3, h4, .display { letter-spacing: -0.02em; font-weight: 800; }
body { line-height: 1.6; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: clip; }
html { overflow-x: clip; }
p, li, td, th, label, .muted { overflow-wrap: anywhere; }

/* Images never stretch; broken images collapse instead of showing an icon */
img { max-width: 100%; height: auto; }
img:not([src]), img[src=""] { visibility: hidden; }

/* Buttons — same height, radius and states everywhere */
.btn { border-radius: 12px; min-height: 40px; font-weight: 700; letter-spacing: 0; transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease); display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn-sm { min-height: 36px; border-radius: 10px; }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-primary { background: var(--accent-grad); color: var(--on-accent); }
.btn-danger { font-weight: 700; }
.btn-line { color: var(--text); }

/* Visible keyboard focus */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent-line); outline-offset: 2px; border-radius: 10px;
}

/* Inputs — same height, radius, focus */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea { border-radius: 10px; }
.field input, .field select, .field textarea, .tcn-input, .tcn-field input, .tcn-field select, .tcn-field textarea { min-height: 44px; font-size: 15px; }
.field label { font-weight: 600; }

/* Cards — consistent radius, soft shadow, smooth hover */
.card, .tcn-card, .tp-card, .tcn-kpi, .tcn-bcard, .tcn-fcard { border-radius: 16px; }
.card.tilt { transition: transform .2s var(--ease), box-shadow .2s var(--ease); }

/* Creator & brand cards: equal heights in grids, long names wrap nicely */
.tcp-grid { align-items: stretch; }
.tcp-card { height: 100%; cursor: pointer; }
.tcp-card:focus-visible { outline: 3px solid var(--accent-line); outline-offset: 3px; }
.tcp-name, .tcp-meta { max-width: 100%; overflow-wrap: anywhere; }
.tcp-photo img { aspect-ratio: 1 / 1; }

/* Toasts */
.tcn-toast { border-radius: 14px; font-weight: 600; box-shadow: var(--shadow-md); }

/* Theme toggle sits above the WhatsApp button on small screens */
#tcnTheme { width: 46px; height: 46px; }

/* Portal: sidebar / topbar polish */
.portal-sidebar-nav .portal-nav-item { min-height: 44px; border-radius: 10px; }
.portal-sidebar-nav .portal-nav-item.active { font-weight: 700; }
.portal-topbar { gap: 10px; }
.portal-topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.portal-topbar-left .current { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-main { min-width: 0; }

/* Tables scroll inside their box, never the page */
.tcn-tablebox, .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Smooth, subtle page entrance */
@keyframes tcFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#publicContent > *, .portal-main > main > * { animation: tcFade .22s var(--ease); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* Mobile: 44px tap targets, readable text, no overflow */
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .btn, .btn-sm { min-height: 44px; }
  .tcn-toolbar { gap: 8px; }
  .tcn-toolbar .tcn-input, .tcn-toolbar select { max-width: none !important; flex: 1 1 100%; }
  .tp-hide-sm { display: none !important; }
  .tcn-head h1 { font-size: 24px !important; }
  .tcn-modal { padding: 12px; }
  .tcn-modal .box { padding: 18px; border-radius: 18px; }
  .portal-topbar { padding-left: 12px; padding-right: 12px; }
  .wa-float .wa-text { display: none; }
}
