/**
 * MedGuide - Main Styles
 * Estilos principais da aplicação
 */

/* ── Design Tokens ── */
:root {
    --topbar-h: 64px;
    --sidebar-w: 256px;
    --sidebar-collapsed: 72px;
    --color-primary: #0d9488;
    --color-primary-dark: #0f766e;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border-light: #f1f5f9;
    --color-border: #e2e8f0;
    --color-text-primary: #0f172a;
    --color-text-secondary: #64748b;
}

/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: #f8fafc;
}

.font-inter {
    font-family: 'Inter', sans-serif;
}

/* Scrollbar customizada */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-10px);
        opacity: 0;
    }
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}

.animate-slide-out {
    animation: slideOut 0.3s ease-out;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Modal animations — used by overlay/dialog across all pages */
.animate-modal {
    animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-overlay {
    animation: fadeIn 0.2s ease-out;
}

/* Cards */
.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    transition: all 0.15s ease;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    outline: none;
}

.btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.25);
}

.btn-primary {
    background: linear-gradient(135deg, #0d9488 0%, #0a7a6f 100%);
    color: #ffffff;
    border-color: #0d9488;
    box-shadow: 0 2px 6px rgba(13, 148, 136, 0.28);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0f766e 0%, #085e55 100%);
    border-color: #0f766e;
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.38);
    transform: translateY(-1px);
}

.btn-primary:active {
    background: #115e59;
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(13, 148, 136, 0.2);
}

.btn-secondary {
    background: #f8fafc;
    color: #475569;
    border-color: #e2e8f0;
}

.btn-secondary:hover {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #cbd5e1;
    transform: translateY(-0.5px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.btn-secondary:active {
    background: #e2e8f0;
}

.btn-outline {
    background: transparent;
    color: #0d9488;
    border-color: #0d9488;
}

.btn-outline:hover {
    background: #f0fdfa;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    border-color: #dc2626;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.22);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.32);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: #64748b;
    border-color: transparent;
}

.btn-ghost:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.btn-success {
    background: #059669;
    color: #ffffff;
    border-color: #059669;
}
.btn-success:hover {
    background: #047857;
}
.btn-success:active {
    background: #065f46;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 0.375rem;
}

.btn-lg {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    border-radius: 0.625rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Inputs — base reset (sem sobrescrever .form-input e .form-select) */
input[type="text"]:not(.form-input):not([class]),
input[type="email"]:not(.form-input):not([class]),
input[type="password"]:not(.form-input):not([class]),
input[type="tel"]:not(.form-input):not([class]),
input[type="number"]:not(.form-input):not([class]),
input[type="date"]:not(.form-input):not([class]),
input[type="time"]:not(.form-input):not([class]),
select:not(.form-select):not([class]),
textarea:not(.form-input):not([class]) {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:disabled,
select:disabled,
textarea:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
}

.badge-blue    { background: #dbeafe; color: #1d4ed8; }
.badge-green   { background: #d1fae5; color: #065f46; }
.badge-yellow  { background: #fef3c7; color: #92400e; }
.badge-red     { background: #fee2e2; color: #991b1b; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-primary { background: #ccfbf1; color: #0f766e; }
.badge-secondary { background: #f1f5f9; color: #64748b; }
.badge-teal    { background: #ccfbf1; color: #0f766e; }
/* New badge variants used by controllers */
.badge-success { background: #d1fae5; color: #065f46; }
.badge-error   { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #f0fdfa; color: #134e4a; }
.badge-slate   { background: #f1f5f9; color: #475569; }
.badge-rose    { background: #ffe4e6; color: #9f1239; }
.badge-emerald { background: #d1fae5; color: #065f46; }
.badge-amber   { background: #fef3c7; color: #92400e; }

/* Sidebar — legacy rules replaced by .app-sidebar in menu.js injected CSS */
#sidebar {
    /* Positioning is handled by .app-sidebar class injected by menu.js */
}

/* Menu */
.menu-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #475569;
    transition: all 0.15s ease;
    position: relative;
    text-decoration: none;
}

.menu-link:hover {
    background: #f8fafc;
    color: #1e293b;
}

.menu-link:hover .menu-icon {
    color: #334155;
}

.menu-link.active {
    background: linear-gradient(to right, #f0fdfa, #f0fdfa);
    color: #0f766e;
    font-weight: 600;
}

.menu-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    background: #0d9488;
    border-radius: 0 3px 3px 0;
}

.menu-icon {
    width: 1.125rem;
    height: 1.125rem;
    color: #94a3b8;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.menu-link.active .menu-icon {
    color: #0d9488;
}

/* Skeleton Loading */
.skeleton {
    background-color: #e2e8f0;
    border-radius: 0.375rem;
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-text {
    height: 1rem;
    background-color: #e2e8f0;
    border-radius: 0.375rem;
    animation: pulse 1.5s ease-in-out infinite;
    display: block;
}

.skeleton-circle {
    border-radius: 9999px;
    background-color: #e2e8f0;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Modal Backdrop */
.modal-backdrop {
    backdrop-filter: blur(4px);
}

/* Notifications */
.notification {
    animation: slideInRight 0.3s ease-out;
}

/* Utilities */
.text-balance {
    text-wrap: balance;
}

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

.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Focus visible */
.focus-ring:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #0d9488, 0 0 0 4px rgba(13,148,136,0.2);
}

/* Print styles */
@media print {
    #sidebar,
    #header,
    .no-print {
        display: none !important;
    }

    body {
        padding: 0;
        margin: 0;
        background: #fff;
    }

    main {
        margin-left: 0;
    }
}

/* Loading state */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0d9488;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   SWEETALERT2 CUSTOM STYLES
   ============================================ */
.swal2-popup {
    border-radius: 30px !important;
    max-height: 85vh !important;
}

.swal2-modal {
    max-height: 85vh !important;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: #94a3b8;
}

.empty-state svg {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    opacity: 0.5;
    display: block;
}

/* Progress bar */
.progress-bar {
    width: 100%;
    background: #e2e8f0;
    border-radius: 9999px;
    height: 0.5rem;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    transition: all 0.5s ease-out;
    border-radius: 9999px;
}

/* Calendar grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.calendar-day:hover {
    background: #f8fafc;
}

.calendar-day.today {
    background: #0d9488;
    color: white;
}

.calendar-day.today:hover {
    background: #0f766e;
}

.calendar-day.has-event {
    background: #f0fdfa;
    color: #0d9488;
    font-weight: 600;
}

/* Status dots */
.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online  { background: #10b981; }
.status-dot.offline { background: #94a3b8; }
.status-dot.away    { background: #f59e0b; }

/* Glass effect */
.glass {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #0d9488 0%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Shadow utilities */
.shadow-soft {
    box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.06);
}

.shadow-medium {
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.10);
}

.shadow-strong {
    box-shadow: 0 8px 24px 0 rgba(0, 0, 0, 0.14);
}

/* ==========================================
   DESIGN TOKENS — Page Structure
   ========================================== */

/* Page wrapper */
.page-content {
    padding: 1.25rem;
    max-width: 100%;
}

@media (min-width: 1024px) {
    .page-content {
        padding: 1.75rem;
    }
}

/* Page header — título + botões de ação */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-header-compact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.875rem;
    color: #64748b;
    margin-top: 0.2rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Section card */
.section-card {
    background: #ffffff;
    border-radius: 0.875rem;
    border: 1px solid #e8edf2;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.03);
    overflow: hidden;
}

.section-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.section-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1e293b;
}

.section-card-body {
    padding: 1.25rem;
}

/* Action link */
.action-link {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #0d9488;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.15s ease;
    text-decoration: none;
}

.action-link:hover {
    color: #0f766e;
}

/* Tooltip via [data-tooltip] attribute */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 0.3rem 0.6rem;
    border-radius: 0.375rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 50;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* Filter bar */
.filter-bar {
    background: #ffffff;
    border: 1px solid #e8edf2;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

/* Search input group */
.search-group {
    position: relative;
    flex: 1;
    min-width: 0;
}

.search-group .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: #94a3b8;
    pointer-events: none;
}

.search-group input {
    width: 100%;
    padding: 0.5rem 0.875rem 0.5rem 2.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: #f8fafc;
    color: #1e293b;
    transition: all 0.15s ease;
    outline: none;
}

.search-group input:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
    background: #ffffff;
}

/* Status badges — modernos */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.625rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
}

.status-badge::before {
    content: '';
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
}

.status-badge.success  { background: #ecfdf5; color: #065f46; }
.status-badge.warning  { background: #fffbeb; color: #92400e; }
.status-badge.error    { background: #fef2f2; color: #991b1b; }
.status-badge.info     { background: #f0fdfa; color: #134e4a; }
.status-badge.neutral  { background: #f8fafc; color: #334155; }
.status-badge.purple   { background: #f5f3ff; color: #5b21b6; }

/* Shimmer skeleton animation */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton-shimmer {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 400px 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: 0.375rem;
}

/* Empty state */
.empty-state-container {
    text-align: center;
    padding: 4rem 2rem;
    color: #94a3b8;
}

.empty-state-icon {
    width: 3.5rem;
    height: 3.5rem;
    margin: 0 auto 1rem;
    opacity: 0.4;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.375rem;
}

.empty-state-desc {
    font-size: 0.875rem;
    color: #94a3b8;
    max-width: 28rem;
    margin: 0 auto 1.5rem;
    line-height: 1.6;
}

/* Table improvements */
.table-container {
    overflow: hidden;
    overflow-x: auto;
    border-radius: 0.875rem;
    border: 1px solid #e8edf2;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* Clip table header top corners to match container radius */
.table-container .data-table thead tr:first-child th:first-child { border-top-left-radius: 0.75rem; }
.table-container .data-table thead tr:first-child th:last-child  { border-top-right-radius: 0.75rem; }

.data-table thead tr {
    background: #f1f5f9;
}

.data-table thead th {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background: #f0fdfa;
}

/* Stat card — refined */
.stat-card-v2 {
    background: #ffffff;
    border: 1px solid #f1f5f9;
    border-radius: 0.875rem;
    padding: 1.25rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.4s ease-out both;
}

/* Stagger entrance for stat cards inside grid */
.stat-card-v2:nth-child(1) { animation-delay: 0ms; }
.stat-card-v2:nth-child(2) { animation-delay: 60ms; }
.stat-card-v2:nth-child(3) { animation-delay: 120ms; }
.stat-card-v2:nth-child(4) { animation-delay: 180ms; }

.stat-card-v2:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border-color: #e2e8f0;
    transform: translateY(-1px);
}

.stat-card-v2-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.stat-card-v2-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1;
    margin-bottom: 0.3rem;
}

.stat-card-v2-label {
    font-size: 0.8125rem;
    color: #64748b;
    font-weight: 500;
}

/* Card with left accent border */
.card-accent-teal   { border-left: 3px solid #0d9488; }
.card-accent-emerald { border-left: 3px solid #059669; }
.card-accent-amber  { border-left: 3px solid #d97706; }
.card-accent-red    { border-left: 3px solid #dc2626; }
.card-accent-purple { border-left: 3px solid #7c3aed; }

/* ================================================================
   APP TOPBAR — Gradient Header
   ================================================================ */

.app-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: linear-gradient(135deg, #0d9488 0%, #0a6b62 100%);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    z-index: 50;
    box-shadow: 0 2px 16px rgba(13, 148, 136, 0.28);
}

/* Brand */
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-shrink: 0;
}

.topbar-mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 0.5rem;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
}
.topbar-mobile-toggle:hover { background: rgba(255,255,255,0.25); }

@media (max-width: 1023px) {
    .topbar-mobile-toggle { display: flex; }
}

.topbar-brand-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: white;
    transition: opacity 0.15s;
}
.topbar-brand-link:hover { opacity: 0.9; color: white; }

.topbar-logo-box {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.18);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.topbar-brand-link:hover .topbar-logo-box { background: rgba(255,255,255,0.28); }

.topbar-brand-name {
    font-size: 1.0625rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

/* Search */
.topbar-search-area {
    width: 100%;
    max-width: 520px;
    justify-self: center;
}

.topbar-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.topbar-search-icon {
    position: absolute;
    left: 0.875rem;
    width: 1rem;
    height: 1rem;
    color: rgba(255,255,255,0.65);
    pointer-events: none;
    flex-shrink: 0;
}

.topbar-search-input {
    width: 100%;
    height: 38px;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: 99px;
    padding: 0 1.125rem 0 2.625rem;
    color: white;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.topbar-search-input::placeholder { color: rgba(255,255,255,0.6); }
.topbar-search-input:hover { border-color: rgba(255,255,255,0.45); }
.topbar-search-input:focus {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.65);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.1);
}

@media (max-width: 640px) {
    .topbar-search-area { display: none; }
}

/* Actions */
.topbar-actions-area {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
    justify-self: end;
}

.topbar-new-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.32);
    border-radius: 0.5rem;
    color: white;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.topbar-new-btn:hover { background: rgba(255,255,255,0.26); color: white; }

@media (max-width: 767px) {
    .topbar-new-btn { display: none; }
}

.topbar-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.12);
    border: none;
    border-radius: 0.5rem;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,0.22); }

.topbar-badge {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 7px;
    height: 7px;
    background: #f43f5e;
    border-radius: 50%;
    border: 2px solid #0d9488;
}

.topbar-divider {
    width: 1px;
    height: 22px;
    background: rgba(255,255,255,0.22);
    margin: 0 0.125rem;
    flex-shrink: 0;
}

/* User button */
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.625rem 0.25rem 0.25rem;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 0.625rem;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}
.topbar-user-btn:hover { background: rgba(255,255,255,0.22); }

.topbar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.topbar-user-info {
    display: none;
    flex-direction: column;
    text-align: left;
}
@media (min-width: 768px) { .topbar-user-info { display: flex; } }

.topbar-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: white;
    line-height: 1.25;
    white-space: nowrap;
}
.topbar-user-role {
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.7);
    line-height: 1.25;
    white-space: nowrap;
}
.topbar-user-chevron {
    color: rgba(255,255,255,0.65);
    display: none;
}
@media (min-width: 768px) { .topbar-user-chevron { display: block; } }

/* User dropdown */
.topbar-user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    width: 216px;
    background: white;
    border-radius: 0.875rem;
    box-shadow: 0 10px 32px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    border: 1px solid #f1f5f9;
    padding: 0.375rem;
    z-index: 100;
    animation: slideIn 0.2s ease-out;
}

.topbar-ud-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem 0.625rem;
}

.topbar-ud-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d9488, #0a6b62);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.topbar-ud-info { flex: 1; overflow: hidden; }
.topbar-ud-info p {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}
.topbar-ud-info small {
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.3;
}

.topbar-ud-divider { height: 1px; background: #f1f5f9; margin: 0.25rem 0; }

.topbar-ud-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5625rem 0.875rem;
    font-size: 0.8125rem;
    color: #334155;
    border-radius: 0.5rem;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.1s;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font-family: inherit;
}
.topbar-ud-item:hover { background: #f8fafc; color: #0f172a; }
.topbar-ud-logout { color: #dc2626; }
.topbar-ud-logout:hover { background: #fef2f2; }

/* Notifications dropdown */
.topbar-notif-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    width: 320px;
    background: white;
    border-radius: 0.875rem;
    box-shadow: 0 10px 32px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    border: 1px solid #f1f5f9;
    overflow: hidden;
    z-index: 100;
    animation: slideIn 0.2s ease-out;
}
.topbar-notif-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-notif-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
}
.topbar-notif-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #0d9488;
}
.topbar-notif-body { max-height: 320px; overflow-y: auto; }
.topbar-notif-empty {
    padding: 2.25rem 1rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.875rem;
}

/* ================================================================
   DASHBOARD STAT CARDS — Gradient icon variant
   ================================================================ */

.stat-card-v3 {
    background: #ffffff;
    border: 1px solid #e8edf2;
    border-radius: 1rem;
    padding: 1.375rem 1.25rem;
    transition: all 0.22s ease;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.4s ease-out both;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 2px 8px rgba(0,0,0,0.03);
}
.stat-card-v3:nth-child(1) { animation-delay: 0ms; }
.stat-card-v3:nth-child(2) { animation-delay: 60ms; }
.stat-card-v3:nth-child(3) { animation-delay: 120ms; }
.stat-card-v3:nth-child(4) { animation-delay: 180ms; }
.stat-card-v3:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.04);
    transform: translateY(-3px);
    border-color: #d1d9e0;
}
.stat-card-v3::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: 1rem 1rem 0 0;
}
.stat-card-v3:hover::after { opacity: 1; }

.stat-v3-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}
.stat-v3-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}
.stat-v3-label {
    font-size: 0.8125rem;
    color: #64748b;
    font-weight: 500;
}

/* Icon color variants + subtle tinted card backgrounds */
.stat-v3-teal   { background: linear-gradient(155deg, #ffffff 55%, #edfaf8 100%); }
.stat-v3-teal   .stat-v3-icon { background: linear-gradient(135deg, #0d9488, #0f766e); }
.stat-v3-teal   .stat-v3-icon svg, .stat-v3-teal .stat-v3-icon i { color: white !important; }
.stat-v3-teal   .stat-v3-value { color: #0f172a; }
.stat-v3-teal::after { background: linear-gradient(90deg, #0d9488, #0f766e); }

.stat-v3-emerald { background: linear-gradient(155deg, #ffffff 55%, #ecfdf5 100%); }
.stat-v3-emerald .stat-v3-icon { background: linear-gradient(135deg, #059669, #047857); }
.stat-v3-emerald .stat-v3-icon svg, .stat-v3-emerald .stat-v3-icon i { color: white !important; }
.stat-v3-emerald .stat-v3-value { color: #0f172a; }
.stat-v3-emerald::after { background: linear-gradient(90deg, #059669, #047857); }

.stat-v3-amber  { background: linear-gradient(155deg, #ffffff 55%, #fffbeb 100%); }
.stat-v3-amber  .stat-v3-icon { background: linear-gradient(135deg, #d97706, #b45309); }
.stat-v3-amber  .stat-v3-icon svg, .stat-v3-amber .stat-v3-icon i { color: white !important; }
.stat-v3-amber  .stat-v3-value { color: #0f172a; }
.stat-v3-amber::after { background: linear-gradient(90deg, #d97706, #b45309); }

.stat-v3-purple { background: linear-gradient(155deg, #ffffff 55%, #f5f3ff 100%); }
.stat-v3-purple .stat-v3-icon { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.stat-v3-purple .stat-v3-icon svg, .stat-v3-purple .stat-v3-icon i { color: white !important; }
.stat-v3-purple .stat-v3-value { color: #0f172a; }
.stat-v3-purple::after { background: linear-gradient(90deg, #7c3aed, #6d28d9); }

.stat-v3-red    { background: linear-gradient(155deg, #ffffff 55%, #fff1f1 100%); }
.stat-v3-red    .stat-v3-icon { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-v3-red    .stat-v3-icon svg, .stat-v3-red .stat-v3-icon i { color: white !important; }
.stat-v3-red    .stat-v3-value { color: #0f172a; }
.stat-v3-red::after { background: linear-gradient(90deg, #ef4444, #dc2626); }

.stat-v3-blue   { background: linear-gradient(155deg, #ffffff 55%, #eff6ff 100%); }
.stat-v3-blue   .stat-v3-icon { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-v3-blue   .stat-v3-icon svg, .stat-v3-blue .stat-v3-icon i { color: white !important; }
.stat-v3-blue   .stat-v3-value { color: #0f172a; }
.stat-v3-blue::after { background: linear-gradient(90deg, #3b82f6, #2563eb); }

.stat-v3-slate  { background: linear-gradient(155deg, #ffffff 55%, #f8fafc 100%); }
.stat-v3-slate  .stat-v3-icon { background: linear-gradient(135deg, #475569, #334155); }
.stat-v3-slate  .stat-v3-icon svg, .stat-v3-slate .stat-v3-icon i { color: white !important; }
.stat-v3-slate  .stat-v3-value { color: #0f172a; }
.stat-v3-slate::after { background: linear-gradient(90deg, #475569, #334155); }

.stat-v3-rose   { background: linear-gradient(155deg, #ffffff 55%, #fff1f2 100%); }
.stat-v3-rose   .stat-v3-icon { background: linear-gradient(135deg, #e11d48, #be123c); }
.stat-v3-rose   .stat-v3-icon svg, .stat-v3-rose .stat-v3-icon i { color: white !important; }
.stat-v3-rose   .stat-v3-value { color: #0f172a; }
.stat-v3-rose::after { background: linear-gradient(90deg, #e11d48, #be123c); }

/* ================================================================
   PHASE 2.4 — Global Improvements
   ================================================================ */

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

/* ── Card base modernizado ── */
.card {
    border-radius: 0.75rem;
    border: 1px solid #f1f5f9;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
}

/* ── Inputs: focus elegante ── */
.form-input:focus, .form-select:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
    outline: none;
}

/* ── Filter bar padronizada ── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.875rem 1rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

/* ── Skeleton loading shimmer ── */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease infinite;
    border-radius: 0.375rem;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Page fade-in ── */
@keyframes page-enter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: page-enter 0.3s cubic-bezier(0.16, 1, 0.3, 1); }

/* ── Card hover lift ── */
.card-hover {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    cursor: pointer;
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}

/* ── Empty state modernizado ── */
.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    gap: 0.75rem;
    min-height: 240px;
}
.empty-state-container .empty-state-icon,
.empty-state-icon { width: 3rem; height: 3rem; opacity: 0.3; }
.empty-state-container .empty-state-title,
.empty-state-title { font-size: 1rem; font-weight: 600; color: #64748b; }
.empty-state-container .empty-state-description,
.empty-state-desc { font-size: 0.875rem; color: #94a3b8; max-width: 320px; }
.empty-state-container .empty-state-action { margin-top: 0.5rem; }

/* ── Form groups ── */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group label { font-size: 0.8125rem; font-weight: 500; color: #374151; margin-bottom: 0; }
.form-hint  { font-size: 0.75rem; color: #94a3b8; }
.form-error-msg { font-size: 0.75rem; color: #ef4444; }

/* ── Input com ícone ── */
.input-with-icon { position: relative; }
.input-with-icon .input-icon {
    position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
    color: #94a3b8; pointer-events: none; width: 1rem; height: 1rem;
}
.input-with-icon .form-input { padding-left: 2.375rem; }

/* ── Escala tipográfica ── */
.text-display { font-size: 1.875rem; font-weight: 700; line-height: 1.2; color: #0f172a; }
.text-heading  { font-size: 1.25rem;  font-weight: 600; line-height: 1.3; color: #0f172a; }
.text-subhead  { font-size: 1rem;     font-weight: 600; line-height: 1.4; color: #1e293b; }
.text-body     { font-size: 0.875rem; font-weight: 400; line-height: 1.5; color: #475569; }
.text-caption  { font-size: 0.75rem;  font-weight: 500; line-height: 1.4; color: #64748b; }

/* ── Btn sistema modernizado ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.375rem; padding: 0.5rem 1rem; border-radius: 0.5rem;
    font-size: 0.875rem; font-weight: 500; line-height: 1.25rem;
    transition: all 0.15s ease; cursor: pointer; border: 1px solid transparent;
    text-decoration: none; white-space: nowrap; outline: none; user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(13,148,136,0.35); }

.btn-primary {
    background: linear-gradient(135deg, #0d9488 0%, #0a7a6f 100%);
    color: #ffffff; border-color: #0d9488;
    box-shadow: 0 1px 3px rgba(13,148,136,0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #0f766e 0%, #085e55 100%);
    box-shadow: 0 4px 12px rgba(13,148,136,0.4); transform: translateY(-1px);
}
.btn-primary:active {
    background: #115e59; transform: translateY(0);
    box-shadow: 0 1px 3px rgba(13,148,136,0.2);
}

.btn-secondary {
    background: #ffffff; color: #374151; border-color: #d1d5db;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; color: #111827; }
.btn-secondary:active { background: #e2e8f0; }

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff; border-color: #ef4444;
    box-shadow: 0 1px 3px rgba(239,68,68,0.3);
}
.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(239,68,68,0.4); transform: translateY(-1px);
}

.btn-outline {
    background: transparent; color: #0d9488; border-color: #0d9488;
}
.btn-outline:hover { background: #f0fdfa; }

.btn-ghost {
    background: transparent; color: #64748b; border-color: transparent;
}
.btn-ghost:hover { background: #f1f5f9; color: #374151; }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; border-radius: 0.375rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; border-radius: 0.625rem; }
.btn-icon { padding: 0.5rem; width: 2.25rem; height: 2.25rem; }
.btn-icon.btn-sm { width: 1.875rem; height: 1.875rem; padding: 0.375rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ================================================================
   PHASE 7 — Responsividade & Acessibilidade
   ================================================================ */

/* ── 7.1 Mobile Responsiveness ── */

/* Modais: largura adaptável em mobile */
.modal-content,
.bg-white.rounded-2xl {
    max-width: min(90vw, 540px);
}

/* Stat cards: sempre 2 colunas em mobile, 4 em desktop */
@media (max-width: 639px) {
    .grid.grid-cols-2.lg\\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    /* Page padding reduzido */
    main.p-4.lg\\:p-6 { padding: 1rem; }
}

/* Tabelas: garante scroll horizontal em qualquer largura */
.table-container {
    -webkit-overflow-scrolling: touch;
}

/* Filter bars: sempre wrap em mobile */
.filter-bar {
    flex-wrap: wrap;
}
.filter-bar .search-group {
    min-width: 200px;
}

/* Grids de cards: 1 coluna em mobile */
@media (max-width: 767px) {
    .grid.md\\:grid-cols-2 {
        grid-template-columns: 1fr;
    }
    .grid.md\\:grid-cols-2.lg\\:grid-cols-3 {
        grid-template-columns: 1fr;
    }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .grid.md\\:grid-cols-2.lg\\:grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Botões de ação em tabelas: nunca cortados */
.data-table .row-actions {
    min-width: max-content;
}

/* ── 7.2 Acessibilidade ── */

/* Focus ring visível em todos os elementos interativos */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #0d9488;
    outline-offset: 2px;
}

/* Garantir que elementos com role=alert sejam anunciados */
[role="alert"] {
    min-height: 1rem;
}

/* Skip to main content (acessibilidade — teclado) */
.skip-to-main {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: #0d9488;
    color: white;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: top 0.15s;
}
.skip-to-main:focus {
    top: 1rem;
}

/* Melhor contraste mínimo para textos informativos */
/* Garante que text-slate-400 em fundo branco seja legível — promove ao menos text-slate-500 */
.text-slate-400 { color: #64748b !important; } /* força slate-500 (#64748b) como mínimo */

/* Redução de movimento para usuários que preferem */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
