/* ========================================
   ClinicSaaS - Tema Profissional Saúde
   Paleta moderna azul/indigo para clínicas
   e consultórios de saúde.
   ======================================== */

/* ── Variáveis de Tema ── */
:root {
    /* Primary: Indigo vibrante */
    --cs-primary: #6366f1;
    --cs-primary-rgb: 99, 102, 241;
    --cs-primary-dark: #4f46e5;
    --cs-primary-light: #a5b4fc;
    --cs-primary-subtle: #eef2ff;

    /* Secondary: Slate */
    --cs-secondary: #475569;
    --cs-secondary-rgb: 71, 85, 105;

    /* Accent: Violet */
    --cs-accent: #8b5cf6;
    --cs-accent-rgb: 139, 92, 246;

    /* Success: Verde esmeralda */
    --cs-success: #10b981;
    --cs-success-rgb: 16, 185, 129;
    --cs-success-subtle: #d1fae5;

    /* Info: Azul céu */
    --cs-info: #3b82f6;
    --cs-info-rgb: 59, 130, 246;
    --cs-info-subtle: #dbeafe;

    /* Warning: Âmbar */
    --cs-warning: #f59e0b;
    --cs-warning-rgb: 245, 158, 11;
    --cs-warning-subtle: #fef3c7;

    /* Danger: Vermelho */
    --cs-danger: #ef4444;
    --cs-danger-rgb: 239, 68, 68;
    --cs-danger-subtle: #fee2e2;

    /* Backgrounds */
    --cs-body-bg: #eef0f8;
    --cs-card-bg: #ffffff;
    --cs-sidebar-bg: linear-gradient(180deg, #1e1b4b 0%, #312e81 50%, #3730a3 100%);
    --cs-sidebar-text: #c7d2fe;
    --cs-sidebar-active: #ffffff;
    --cs-sidebar-active-rgb: 255, 255, 255;
    --cs-header-bg: #ffffff;

    /* Text */
    --cs-text-dark: #1e1b4b;
    --cs-text-muted: #64748b;
    --cs-text-light: #94a3b8;
    --cs-border: #e2e8f0;
}

/* ── Body ── */
body {
    background-color: var(--cs-body-bg) !important;
    color: var(--cs-text-dark);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Primary Color Overrides ── */
.bg-primary,
.btn-primary {
    background-color: var(--cs-primary) !important;
    border-color: var(--cs-primary) !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--cs-primary-dark) !important;
    border-color: var(--cs-primary-dark) !important;
    box-shadow: 0 4px 12px rgba(var(--cs-primary-rgb), 0.3) !important;
}

.btn-outline-primary {
    color: var(--cs-primary) !important;
    border-color: var(--cs-primary) !important;
}

.btn-outline-primary:hover {
    background-color: var(--cs-primary) !important;
    border-color: var(--cs-primary) !important;
    color: #fff !important;
}

.text-primary {
    color: var(--cs-primary) !important;
}

.bg-primary-subtle {
    background-color: var(--cs-primary-subtle) !important;
}

/* ── Success ── */
.bg-success-subtle { background-color: var(--cs-success-subtle) !important; }
.text-success { color: var(--cs-success) !important; }
.btn-outline-success { color: var(--cs-success) !important; border-color: var(--cs-success) !important; }
.btn-outline-success:hover { background-color: var(--cs-success) !important; border-color: var(--cs-success) !important; color: #fff !important; }

/* ── Info ── */
.bg-info-subtle { background-color: var(--cs-info-subtle) !important; }
.text-info { color: var(--cs-info) !important; }

/* ── Warning ── */
.bg-warning-subtle { background-color: var(--cs-warning-subtle) !important; }
.text-warning { color: var(--cs-warning) !important; }
.btn-outline-warning { color: var(--cs-warning) !important; border-color: var(--cs-warning) !important; }
.btn-outline-warning:hover { background-color: var(--cs-warning) !important; border-color: var(--cs-warning) !important; color: #fff !important; }

/* ── Danger ── */
.bg-danger-subtle { background-color: var(--cs-danger-subtle) !important; }
.text-danger { color: var(--cs-danger) !important; }
.btn-outline-danger { color: var(--cs-danger) !important; border-color: var(--cs-danger) !important; }
.btn-outline-danger:hover { background-color: var(--cs-danger) !important; border-color: var(--cs-danger) !important; color: #fff !important; }

/* ── Sidebar ── */
.left-sidebar {
    background: var(--cs-sidebar-bg);
    border-right: none;
    box-shadow: 4px 0 16px rgba(30, 27, 75, 0.15);
}

.left-sidebar .sidebar-nav .sidebar-item .sidebar-link {
    color: var(--cs-sidebar-text) !important;
    border-radius: 10px;
    margin: 2px 12px;
    padding: 10px 14px;
    transition: all 0.2s ease;
}

.left-sidebar .sidebar-nav .sidebar-item .sidebar-link:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
}

.left-sidebar .sidebar-nav .sidebar-item .sidebar-link.active,
.left-sidebar .sidebar-nav .sidebar-item.selected > .sidebar-link {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    font-weight: 600;
}

.left-sidebar .sidebar-nav .sidebar-item .sidebar-link.active iconify-icon,
.left-sidebar .sidebar-nav .sidebar-item.selected > .sidebar-link iconify-icon {
    color: #fff !important;
}

.left-sidebar .sidebar-nav .sidebar-item .sidebar-link iconify-icon {
    color: var(--cs-sidebar-text) !important;
    transition: color 0.2s ease;
}

.left-sidebar .sidebar-nav .sidebar-item .sidebar-link:hover iconify-icon {
    color: #fff !important;
}

/* Sidebar submenu */
.left-sidebar .sidebar-nav .collapse.first-level .sidebar-item .sidebar-link {
    padding-left: 24px !important;
    margin: 1px 12px 1px 20px;
    font-size: 0.875rem;
}

/* Sidebar submenu active/hover */
.left-sidebar .sidebar-nav ul .sidebar-item .first-level .sidebar-item .sidebar-link.active {
    color: #fff !important;
}

.left-sidebar .sidebar-nav ul .sidebar-item .first-level .sidebar-item .sidebar-link:hover {
    color: #fff !important;
}

.left-sidebar .sidebar-nav ul .sidebar-item .first-level .sidebar-item .sidebar-link.active .icon-small {
    background: #fff !important;
}

.left-sidebar .sidebar-nav ul .sidebar-item .first-level .sidebar-item .sidebar-link:hover .icon-small {
    background: #fff !important;
}

/* Sidebar section title */
.left-sidebar .sidebar-nav .nav-small-cap {
    color: var(--cs-sidebar-caption, rgba(199, 210, 254, 0.45));
    padding: 16px 26px 8px;
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 1.2px;
}

.left-sidebar .sidebar-nav .nav-small-cap .nav-small-cap-icon {
    color: rgba(199, 210, 254, 0.25) !important;
}

/* Brand logo area */
.left-sidebar .brand-logo {
    padding: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100%;
}

.sidebar-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Close btn mobile */
.left-sidebar .close-btn i {
    color: var(--cs-sidebar-text) !important;
}

/* Sidebar arrow */
.left-sidebar .sidebar-nav .has-arrow::after {
    border-color: var(--cs-sidebar-text) !important;
}

.left-sidebar .sidebar-nav .sidebar-item.selected > .has-arrow::after,
.left-sidebar .sidebar-nav .has-arrow:hover::after {
    border-color: #fff !important;
}

/* ── Header/Navbar ── */
.app-header {
    top: 0 !important;
    background: var(--cs-header-bg) !important;
    border-bottom: 1px solid var(--cs-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    height: 70px;
    min-height: 70px;
}

.app-header .navbar {
    background: transparent !important;
    height: 70px;
    min-height: 70px;
}

/* ── Header User Area ── */
.nav-user-link {
    display: flex !important;
    align-items: center !important;
    padding: 6px 8px !important;
    border-radius: 10px !important;
    transition: background-color 0.2s ease !important;
}

.nav-user-link:hover {
    background-color: var(--cs-body-bg) !important;
}

.nav-user-avatar {
    position: relative;
}

.nav-user-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: var(--cs-success);
    border: 2px solid #fff;
    border-radius: 50%;
}

/* ── Cards ── */
.card {
    background: var(--cs-card-bg);
    border: 1px solid var(--cs-border);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.card-title {
    color: var(--cs-text-dark) !important;
    font-weight: 600;
}

/* ── Icon Circles ── */
.round-48 {
    width: 48px;
    height: 48px;
    border-radius: 12px !important;
}

/* ── Tables ── */
.table {
    --bs-table-bg: transparent;
}

.table thead th {
    font-weight: 600;
    color: var(--cs-text-muted) !important;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--cs-border) !important;
    padding: 12px 16px;
}

.table thead th h6 {
    font-weight: 600 !important;
    color: var(--cs-text-muted) !important;
    text-transform: uppercase;
    font-size: 0.75rem !important;
    letter-spacing: 0.5px;
    margin: 0 !important;
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--cs-text-dark);
    vertical-align: middle;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Badges ── */
.badge {
    font-weight: 500;
    letter-spacing: 0.3px;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.78rem;
}

/* ── Buttons ── */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    letter-spacing: 0.2px;
}

.btn-sm {
    border-radius: 6px;
}

/* Quick actions */
.d-grid .btn {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.9rem;
    border-radius: 10px;
}

.d-grid .btn:hover {
    transform: translateX(4px);
}

/* ── Alerts ── */
.alert {
    border-radius: 10px;
    border: none;
    font-weight: 500;
}

.alert-success {
    background-color: var(--cs-success-subtle);
    color: #065f46;
}

.alert-danger {
    background-color: var(--cs-danger-subtle);
    color: #991b1b;
}

/* ── Form Controls ── */
.form-control,
.form-select {
    border: 1.5px solid var(--cs-border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--cs-primary);
    box-shadow: 0 0 0 3px rgba(var(--cs-primary-rgb), 0.15);
}

.form-label {
    font-weight: 500;
    color: var(--cs-text-dark);
    font-size: 0.875rem;
    margin-bottom: 6px;
}

/* ── Dropdown menus ── */
.dropdown-menu {
    border: 1px solid var(--cs-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.04);
    padding: 6px;
    animation: dropdownFade 0.15s ease;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-menu .dropdown-item,
.dropdown-menu a {
    border-radius: 8px;
    transition: background-color 0.15s ease;
}

.dropdown-menu .dropdown-item:hover,
.dropdown-menu a:hover {
    background-color: var(--cs-primary-subtle);
    color: var(--cs-primary-dark);
}

/* ── User Profile Dropdown ── */
.dropdown-menu .message-body .d-flex.align-items-center.gap-3 {
    padding: 12px 16px !important;
}

.dropdown-menu .message-body h6 {
    color: var(--cs-text-dark);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── Stats cards number ── */
.fs-7 {
    color: var(--cs-text-dark) !important;
}

/* ── Text helpers ── */
.text-muted {
    color: var(--cs-text-muted) !important;
}

/* ── Links ── */
a {
    color: var(--cs-primary);
    transition: color 0.15s ease;
}

a:hover {
    color: var(--cs-primary-dark);
}

/* ── Page title breadcrumb ── */
.page-title {
    font-weight: 700;
    color: var(--cs-text-dark);
}

/* ── Sidebar Layout Fix ── */
#main-wrapper[data-layout="vertical"][data-sidebar-position="fixed"] .left-sidebar {
    top: 0;
}

.left-sidebar .scroll-sidebar {
    height: calc(100vh - 90px);
}

/* ── Main content (desktop) ── */
#main-wrapper[data-layout="vertical"][data-header-position="fixed"] .body-wrapper > .container-fluid {
    padding-top: calc(70px + 24px);
}

/* ── Main content (tablet & mobile) ── */
@media (max-width: 991.98px) {
    .app-header {
        top: 0 !important;
        height: 60px;
        min-height: 60px;
    }
    .app-header .navbar {
        height: 60px;
        min-height: 60px;
    }
    .body-wrapper .container-fluid {
        padding-top: 80px !important;
    }
}

@media (max-width: 575.98px) {
    .app-header {
        top: 0 !important;
    }
    .body-wrapper .container-fluid {
        padding-top: 80px !important;
    }
}

/* ── Tom Select (Combobox pesquisavel) ── */
.ts-wrapper.form-select {
    padding: 0;
    border: none;
}
.ts-wrapper .ts-control {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    min-height: calc(1.5em + 0.75rem + 2px);
    padding: 0.375rem 0.75rem;
    background-color: #fff;
}
.ts-wrapper .ts-control:focus,
.ts-wrapper.focus .ts-control {
    border-color: var(--cs-primary, #0d9488);
    box-shadow: 0 0 0 0.2rem rgba(var(--cs-primary-rgb, 13, 148, 136), 0.15);
}
.ts-wrapper .ts-dropdown {
    border-color: #dee2e6;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.1);
}
.ts-wrapper .ts-dropdown .active {
    background-color: var(--cs-primary-subtle, #ccfbf1);
    color: var(--cs-primary-dark, #0a7a70);
}
.ts-wrapper .ts-dropdown .ts-dropdown-content .option {
    padding: 0.5rem 0.75rem;
}
.ts-wrapper .ts-dropdown .dropdown-input {
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 0.375rem 0.75rem;
    margin: 0.25rem 0.5rem;
    width: calc(100% - 1rem);
}

/* ── Badge Teleconsulta (purple) ── */
.bg-purple-subtle {
    background-color: rgba(139, 92, 246, 0.15) !important;
}
.text-purple {
    color: #7c3aed !important;
}
