/* ================================================================
   UI POLISH — Acceso Residencial
   Non-destructive visual enhancement layer.
   Loads AFTER app-v2.css / theme-v2.css.
   ================================================================ */

/* ── 1. Global Transitions ─────────────────────────────────────── */
*,
*::before,
*::after {
  transition-property: background-color, border-color, color, box-shadow, opacity, transform;
  transition-duration: 0ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 1b. Lucide Icon Sizing ─────────────────────────────────────── */
svg.lucide {
  display: inline-block;
  flex-shrink: 0;
}
.side-nav a svg.lucide {
  width: 24px !important;
  height: 24px !important;
  flex: none !important;
  padding: 0 !important;
  border-radius: 0;
  color: inherit;
  background: none !important;
  box-sizing: border-box;
  transition: all 0.2s ease;
}
body[class*="role-"] .side-nav a:hover svg.lucide,
body[class*="role-"] .side-nav a:focus svg.lucide {
  color: rgba(255, 255, 255, 0.85);
}
body[class*="role-"] .side-nav a.active svg.lucide {
  color: #ffffff;
}
.access-action-btn svg.lucide {
  width: 20px !important;
  height: 20px !important;
}
.resident-action-card span svg.lucide {
  width: 32px !important;
  height: 32px !important;
}
.security-action-glyph svg.lucide {
  width: 24px !important;
  height: 24px !important;
}
.action-icon svg.lucide {
  width: 20px !important;
  height: 20px !important;
}
.payment-row-actions .action-icon {
  border: none !important;
}
.payment-row-actions .action-icon svg {
  width: 20px;
  height: 20px;
}

a, button, input, select, textarea,
.slide-panel-close,
.hamburger-button,
.nav-icon,
.payment-badge,
.calendar-chip,
.calendar-event,
.theme-card,
.download-item,
.btn-grid a,
.btn-grid button,
.access-action-btn,
.resident-card-actions a,
.resident-card-actions button,
.resident-service-actions a,
.resident-service-actions button,
.catalog-actions a,
.catalog-actions button,
.maint-actions a,
.maint-actions button,
.survey-card-actions a,
.survey-card-actions button,
.review-actions a,
.review-actions button,
.service-review-actions a,
.service-review-actions button,
.favorite-actions a,
.favorite-actions button,
.resident-link-list a {
  transition-duration: 80ms;
}

button, a, input, select, textarea {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 2. Focus-Visible Ring ─────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--ui-teal, #0b7a75);
  outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--ui-teal, #0b7a75) !important;
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.15) !important;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ui-teal, #0b7a75);
  outline-offset: 2px;
}

/* ── 3. Sidebar Refinements ────────────────────────────────────── */
.sidebar {
  transition: padding 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  text-decoration: none;
  font-weight: 700;
}

.sidebar-residential-logo {
  transition: transform 0.2s ease;
}

.sidebar-residential-logo:hover {
  transform: scale(1.05);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ui-teal, #0b7a75);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.side-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}

.side-nav a .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 0.15s ease;
}

.side-nav a:hover .nav-icon,
.side-nav a:focus .nav-icon,
.side-nav a.active .nav-icon {
  opacity: 1;
}

.side-nav a.active {
  background: rgba(11, 122, 117, 0.12);
  color: var(--ui-teal, #0b7a75);
  font-weight: 700;
}

.side-nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ui-teal, #0b7a75);
}

.nav-logout-link {
  margin-top: 12px;
  opacity: 0.6;
}

.nav-logout-link:hover {
  opacity: 1;
}

/* ── 4. Topbar Refinements ─────────────────────────────────────── */
.topbar {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.topbar strong {
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── 5. Panel / Card Refinements ───────────────────────────────── */
.panel {
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 6px 16px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.panel:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
}

.resident-welcome-card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 6px 16px rgba(0, 0, 0, 0.04);
}

.resident-welcome-card:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
}

/* ── 6. Button Refinements ─────────────────────────────────────── */
button,
.button-link {
  position: relative;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

button:not(:disabled):hover,
.button-link:hover {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

button:not(:disabled):active,
.button-link:active {
  transform: scale(0.97);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

button.danger {
  box-shadow: 0 1px 2px rgba(180, 35, 24, 0.15);
}

button.danger:hover {
  box-shadow: 0 2px 8px rgba(180, 35, 24, 0.25);
}

.secondary-button,
.button-link.secondary {
  background: var(--ui-surface-2, #f8fafc);
  color: var(--ui-ink-soft, #475467);
  border: 1px solid var(--ui-line, #d9e0e8);
}

.secondary-button:hover,
.button-link.secondary:hover {
  background: var(--ui-surface, #ffffff);
  border-color: var(--ui-line-strong, #b8c2cc);
}

/* ── 7. Input / Select Refinements ─────────────────────────────── */
input,
select,
textarea {
  border-radius: 8px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--ui-line-strong, #b8c2cc);
}

label {
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}

/* ── 8. Table Refinements ──────────────────────────────────────── */
table {
  border-collapse: separate;
  border-spacing: 0;
}

th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-muted, #667085);
  background: var(--ui-surface-2, #f8fafc);
}

tr:not(:first-child) td {
  transition: background-color 0.15s ease;
}

tr:hover td {
  background: rgba(11, 122, 117, 0.03);
}

.row-actions button,
.action-icon {
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.row-actions button:hover,
.action-icon:hover {
  transform: scale(1.1);
}

.row-actions button:active,
.action-icon:active {
  transform: scale(0.95);
}

/* ── 9. Badge Refinements ──────────────────────────────────────── */
.payment-badge {
  letter-spacing: 0.03em;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ── 10. Flash Messages ────────────────────────────────────────── */
.message {
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.message.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.message.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

/* ── 11. Slide Panel ───────────────────────────────────────────── */
.slide-panel {
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
}

.slide-panel-header h2 {
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── 12. Toast ─────────────────────────────────────────────────── */
.toast {
  border-radius: 10px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* ── 13. Calendar Event ────────────────────────────────────────── */
.calendar-event {
  border-radius: 10px;
  transition: background-color 0.15s ease, border-left-color 0.15s ease;
}

.calendar-event:hover {
  background: var(--ui-surface-2, #f8fafc);
}

/* ── 14. Metric Cards ──────────────────────────────────────────── */
.metric-card {
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* ── 15. Security Mode Buttons ─────────────────────────────────── */
.security-mode-button {
  border-radius: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.security-mode-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 48px rgba(49, 151, 232, 0.25);
}

.security-mode-button.pin-mode:hover {
  box-shadow: 0 20px 48px rgba(71, 84, 103, 0.2);
}

/* ── 16. Theme Cards ───────────────────────────────────────────── */
.theme-card {
  border-radius: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.theme-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: var(--ui-line-strong, #b8c2cc);
}

/* ── 17. Download Items ────────────────────────────────────────── */
.download-item {
  border-radius: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.download-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* ── 18. QR Preview ────────────────────────────────────────────── */
.qr-preview img {
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* ── 19. Hamburger Button ──────────────────────────────────────── */
.hamburger-button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 6px;
}

.hamburger-button .hamburger-icon {
  width: 22px;
  height: 22px;
  color: var(--ui-ink, #111827);
}

.hamburger-button .hamburger-close {
  display: none;
}

.hamburger-button[aria-expanded="true"] .hamburger-open {
  display: none;
}

.hamburger-button[aria-expanded="true"] .hamburger-close {
  display: block;
}

/* ── 20. Scrollbar ─────────────────────────────────────────────── */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

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

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.slide-panel-body::-webkit-scrollbar {
  width: 4px;
}

.slide-panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.slide-panel-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
}

/* ── 21. Payment Grid ──────────────────────────────────────────── */
.payment-grid th {
  border-radius: 0;
}

.payment-grid td {
  transition: background-color 0.15s ease;
}

/* ── 22. Resident Action Grid ──────────────────────────────────── */
.resident-action-grid a {
  border-radius: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.resident-action-grid a:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* ── 23. Form Grid / Inline Form ───────────────────────────────── */
.form {
  gap: 18px;
}

.form label {
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── 24. Button Grid (action buttons at bottom) ────────────────── */
.btn-grid a,
.btn-grid button,
.btn-grid .button-link {
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ── 25. Access Action Buttons ─────────────────────────────────── */
.access-action-btn {
  border-radius: 10px;
  font-weight: 600;
}

.access-action-btn svg {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

.access-action-btn:hover svg {
  opacity: 1;
}

/* ── 26. Volver Button ─────────────────────────────────────────── */
.access-volver-link {
  font-weight: 700;
  border-radius: 10px;
}

/* ── 27. Login Page ────────────────────────────────────────────── */
.login-download {
  margin-top: 20px;
}

.oauth-actions button,
.oauth-actions a {
  border-radius: 10px;
}

/* ── 28. Checkbox ──────────────────────────────────────────────── */
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--ui-teal, #0b7a75);
  border-radius: 4px;
}

/* ── 29. Smooth scroll ─────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
}

/* ── 30. Selection color ───────────────────────────────────────── */
::selection {
  background: rgba(11, 122, 117, 0.2);
  color: inherit;
}

/* ── 31. Ops Panel Heading ─────────────────────────────────────── */
.ops-panel-heading {
  border-radius: var(--ui-radius, 8px) var(--ui-radius, 8px) 0 0;
}

.ops-panel-heading b {
  border-radius: 10px;
}

/* ── 32. Ops List Rows ─────────────────────────────────────────── */
.ops-list-row {
  transition: background-color 0.15s ease;
}

.ops-list-row:hover {
  background: rgba(11, 122, 117, 0.03);
}

/* ── 33. Detail Grid List ──────────────────────────────────────── */
.detail-grid-list div {
  padding: 8px 0;
  border-bottom: 1px solid var(--ui-line, #d9e0e8);
}

.detail-grid-list div:last-child {
  border-bottom: 0;
}

/* ── 34. Access Token Card ─────────────────────────────────────── */
.access-token-card {
  border-radius: var(--ui-radius, 8px);
}

/* ── 35. Pin Display ───────────────────────────────────────────── */
.pin-display {
  letter-spacing: 0.15em;
  font-weight: 800;
}

/* ── 36. Filter Actions ────────────────────────────────────────── */
.filter-actions {
  align-items: end;
}

/* ── 37. Media Queries – Mobile Polish ─────────────────────────── */
@media (max-width: 820px) {
  .side-nav a {
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .metric-card {
    min-height: 100px;
    padding: 16px;
  }

  .security-mode-button {
    min-height: 160px;
    padding: 20px;
  }

  .security-mode-button strong {
    font-size: 2.2rem;
  }

  .btn-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (max-width: 480px) {
  .btn-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .security-mode-picker {
    grid-template-columns: 1fr !important;
  }
}

/* ── 38. Print Styles ──────────────────────────────────────────── */
@media print {
  .sidebar,
  .topbar,
  .hamburger-button,
  .nav-scrim,
  .slide-panel-overlay,
  .toast-container {
    display: none !important;
  }

  .app-shell {
    display: block !important;
  }

  .main-area {
    border: 0 !important;
    border-radius: 0 !important;
  }

  .page {
    width: 100% !important;
    margin: 0 !important;
  }
}
