@import url("./components.css");

:root {
    --primary: #5a5981;
    --primary-dark: #3f3e5d;
    --primary-light: #e8e7f2;
    --text-muted: #797c9b;
    --bg-body: #f6f6f6;
    --bg-card: #ffffff;
    --text-main: #3f3e5d;
    --input-border: #e0e0e0;
    --white: #ffffff;
    --nav-bg: #ffffff;
    --text-title: var(--primary);
    --feedback-success-bg: #dff3e7;
    --feedback-success-border: #9bd0b3;
    --feedback-success-text: #1f6a3f;
    --feedback-error-bg: #fbe4e6;
    --feedback-error-border: #efb0b7;
    --feedback-error-text: #9b2531;
    --feedback-info-bg: #e7effa;
    --feedback-info-border: #b6caee;
    --feedback-info-text: #1e3f76;
    --feedback-warning-bg: #fff3df;
    --feedback-warning-border: #f3d3a0;
    --feedback-warning-text: #7f4a05;
    --feedback-shadow: 0 12px 24px rgba(40, 32, 72, 0.2);
    
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
}

.dark-mode {
    --bg-body: #3d415e;
    --bg-card: #2c2f48;
    --primary-light: #3f3e5d;
    --text-main: #f6f6f6;
    --text-muted: #a0a3bd;
    --input-border: #5a5981;
    --nav-bg: #2c2f48;
    --text-title: #f6f6f6;
    --feedback-success-bg: color-mix(in srgb, #284b36 62%, var(--bg-card));
    --feedback-success-border: color-mix(in srgb, #4f906b 60%, var(--input-border));
    --feedback-success-text: #d9f2e5;
    --feedback-error-bg: color-mix(in srgb, #5a232b 68%, var(--bg-card));
    --feedback-error-border: color-mix(in srgb, #b05562 55%, var(--input-border));
    --feedback-error-text: #ffd8dd;
    --feedback-info-bg: color-mix(in srgb, #213b5a 70%, var(--bg-card));
    --feedback-info-border: color-mix(in srgb, #4e79ae 52%, var(--input-border));
    --feedback-info-text: #d8e8ff;
    --feedback-warning-bg: color-mix(in srgb, #5a3d1f 72%, var(--bg-card));
    --feedback-warning-border: color-mix(in srgb, #b47f43 56%, var(--input-border));
    --feedback-warning-text: #ffe8cc;
    --feedback-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

.btn-primary {
    padding: 0.8rem 2rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    transition: background-color 0.3s;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-primary:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    padding: 0.8rem 2rem;
    background-color: var(--bg-body);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 10px;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    transition: all 0.3s ease;
}

.dark-mode .btn-secondary {
    color: var(--white);
}

.btn-secondary:hover {
    background-color: var(--primary);
    color: white;
}

.form-label-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.form-label-actions label {
    margin: 0;
}

.btn-inline-action {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    gap: 0.4rem;
}

input, textarea, select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    font-size: 1rem;
    background-color: var(--bg-card);
    color: var(--text-main);
    transition: all 0.3s ease;
}

input[type="time"] {
    min-width: 7rem;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 5px rgba(90, 89, 129, 0.3);
}

.switch-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--text-title);
    font-size: 0.88rem;
    line-height: 1.25;
    cursor: pointer;
}

.switch-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

.switch-ui {
    display: inline-block;
    flex-shrink: 0;
    width: 42px;
    height: 27px;
    border-radius: 999px;
    border: 1px solid var(--input-border);
    background: #d9deec;
    background: color-mix(in srgb, var(--input-border) 80%, #b0b9d7 20%);
    position: relative;
    transition: background 0.2s ease;
}

.switch-ui::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.switch-toggle input[type="checkbox"]:checked + .switch-ui {
    background: var(--primary);
}

.switch-toggle input[type="checkbox"]:checked + .switch-ui::after {
    transform: translateX(18px);
}

.switch-toggle input[type="checkbox"]:focus-visible + .switch-ui {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}

.switch-text {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.toggle-switch-field {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    width: fit-content;
    border: 1px solid var(--input-border);
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    background: var(--bg-card);
    cursor: pointer;
    user-select: none;
}

.toggle-switch-field input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

.toggle-switch-control {
    width: 44px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid var(--input-border);
    background: color-mix(in srgb, var(--bg-body) 75%, #d9deec);
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.toggle-switch-control::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 2px;
    left: 2px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.toggle-switch-field input[type="checkbox"]:checked + .toggle-switch-control {
    background: color-mix(in srgb, var(--primary) 72%, #6a88ff);
    border-color: color-mix(in srgb, var(--primary) 60%, #4e65b5);
}

.toggle-switch-field input[type="checkbox"]:checked + .toggle-switch-control::after {
    transform: translateX(20px);
}

.toggle-switch-field input[type="checkbox"]:focus-visible + .toggle-switch-control {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}

.dark-mode .toggle-switch-control {
    background: #4b5179;
    border-color: #727aa8;
}

.dark-mode .toggle-switch-control::after {
    background: #f2f5ff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.dark-mode .toggle-switch-field input[type="checkbox"]:checked + .toggle-switch-control {
    background: #1f9a6f;
    border-color: #39c08f;
    box-shadow: 0 0 0 2px rgba(57, 192, 143, 0.2);
}

.toggle-switch-text {
    color: var(--text-title);
    font-weight: 600;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

/* Page Layout Components */
.pills-container, .role-pills-container {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.pill-checkbox, .role-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 16px;
    border-radius: 25px;
    border: 2px solid var(--input-border);
    background-color: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.pill-checkbox i, .role-pill i {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.pill-checkbox.selected, .role-pill.selected {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(90, 89, 129, 0.3);
}

.pill-checkbox:hover, .role-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pill-checkbox.selected:hover, .role-pill.selected:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.dark-mode .pill-checkbox:not(.selected):hover, 
.dark-mode .role-pill:not(.selected):hover {
    color: white;
}

.header-section {
    margin-bottom: 2rem;
}

.header-section h1 {
    color: var(--text-title);
    margin-bottom: 0.2rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-section {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: center;
}

/* Tables and Data Lists */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.8rem;
}

.data-table th {
    text-align: left;
    padding: 0 1.5rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
}

.data-table td {
    padding: 1rem 1.5rem;
    background-color: var(--primary-light);
    transition: background-color 0.3s;
    color: var(--text-main);
    /*border-radius: 12px;*/
}

.data-table td:first-child {
    border-radius: 12px 0 0 12px;
}

.data-table td:last-child {
    border-radius: 0 12px 12px 0;
}

.data-table tr {
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

/* Status Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
    white-space: nowrap;
}

.status-agendada { background: #e3f2fd; color: #1976d2; }
.status-confirmada { background: #e8f5e9; color: #2e7d32; }
.status-cancelada { background: #ffebee; color: #c62828; }
.status-noshow, .status-no_show { background: #fff3e0; color: #ef6c00; }
.status-finalizada, .status-concluida { background: #f3e5f5; color: #7b1fa2; }
.status-em_andamento { background: #fff9c4; color: #856404; }
.status-active { background: #e8f5e9; color: #2e7d32; }
.status-inactive { background: #ffebee; color: #c62828; }

.action-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-action-small {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-confirm { background-color: #e8f5e9; color: #2e7d32; }
.btn-confirm:hover { background-color: #2e7d32; color: white; }

.btn-cancel { background-color: #ffebee; color: #c62828; }
.btn-cancel:hover { background-color: #c62828; color: white; }

.btn-noshow { background-color: #fff3e0; color: #ef6c00; }
.btn-noshow:hover { background-color: #ef6c00; color: white; }

.btn-start { background-color: #e3f2fd; color: #1976d2; }
.btn-start:hover { background-color: #1976d2; color: white; }

.btn-finish { background-color: #f3e5f5; color: #7b1fa2; }
.btn-finish:hover { background-color: #7b1fa2; color: white; }

.btn-record { background-color: #e8eaf6; color: #3949ab; }
.btn-record:hover { background-color: #3949ab; color: white; }

.search-box {
    position: relative;
    flex: 1;
}

.search-box input {
    width: 100%;
    padding: 1rem 1.5rem 1rem 3.5rem;
    border-radius: 15px;
    border: none;
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.search-box input:focus {
    outline: none;
    box-shadow: 0 4px 15px rgba(90, 89, 129, 0.2);
}

/* Split Button */
.btn-group {
    display: inline-flex;
    align-items: stretch;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn-group .btn-primary {
    border-radius: 0;
    padding: 1rem 2rem;
}

.btn-group .btn-add {
    background-color: var(--primary-dark);
    padding: 1rem 1.5rem;
    border-left: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-group .btn-add:hover {
    background-color: var(--primary);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
}

/* Pre-render: prevent FOUC on page navigation */
#userName:not(.ready) {
    visibility: hidden;
}

html.pre-sidebar-retracted .sidebar {
    width: var(--sidebar-collapsed-width);
}
html.pre-sidebar-retracted .sidebar .nav-text,
html.pre-sidebar-retracted .sidebar .admin-nav-title,
html.pre-sidebar-retracted .sidebar .sidebar-logo {
    display: none;
}
html.pre-sidebar-retracted .sidebar .nav-item {
    justify-content: center;
    padding: 0.8rem 0;
}
html.pre-sidebar-retracted .sidebar .sidebar-header {
    justify-content: center;
    padding: 0;
}
html.pre-sidebar-retracted .sidebar + .main-wrapper {
    margin-left: calc(var(--sidebar-collapsed-width) + 15px);
}

/* Sidebar Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    height: calc(100vh - 30px);
    position: fixed;
    left: 15px;
    top: 15px;
    z-index: 1000;
    transition: width 0.3s ease, left 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 15px;
    box-shadow: 4px 4px 15px rgba(0,0,0,0.05);
}

.sidebar.retracted {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    height: 70px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    font-weight: bold;
    color: var(--text-title);
    font-size: 1.2rem;
    white-space: nowrap;
    overflow: hidden;
    height: 100%;
}

.clinic-sidebar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.clinic-sidebar-brand-logo {
    width: 30px;
    height: 30px;
    border-radius: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--input-border));
    color: var(--primary);
}

.clinic-sidebar-brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.clinic-sidebar-brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logo-full {
    display: inline-block;
    transition: opacity 0.3s, width 0.3s;
}

.logo-mini {
    display: none;
    font-size: 1.4rem;
}

.sidebar.retracted .sidebar-logo {
    display: none;
}

.sidebar.retracted .sidebar-header {
    justify-content: center;
    padding: 0;
}

.sidebar.retracted .logo-full {
    opacity: 0;
    width: 0;
    display: none;
}

.sidebar.retracted .logo-mini {
    display: none;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1rem;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.sidebar-toggle:hover {
    background-color: var(--bg-body);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    padding: 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--text-muted) 65%, #8b95aa);
    border-radius: 999px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    text-decoration: none;
    color: var(--text-main);
    border-radius: 10px;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-item:hover {
    background-color: var(--bg-body);
    color: var(--primary);
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
}

.nav-icon {
    font-size: 1.1rem;
    min-width: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nav-text {
    margin-left: 10px;
    transition: opacity 0.3s;
}

.sidebar.retracted .nav-item {
    justify-content: center;
    padding: 0.8rem 0;
}

.sidebar.retracted .nav-text {
    display: none;
}

.admin-nav-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--input-border);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.admin-nav-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 1rem;
    margin-bottom: .3rem;
}

.admin-nav-title.admin-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.admin-nav-toggle-icon {
    font-size: 0.72rem;
    transition: transform 0.2s ease;
}

.admin-nav-section.collapsed .admin-nav-toggle-icon {
    transform: rotate(-90deg);
}

.admin-nav-section.collapsed > .nav-item {
    display: none !important;
}

.sidebar.retracted .admin-nav-section.collapsed > .nav-item {
    display: flex !important;
}

.sidebar.retracted .admin-nav-title {
    display: none;
}

/* In-progress nav section (Andamento) */
.in-progress-nav-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--input-border);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.in-progress-nav-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--success-color, #28a745);
    padding: 0 1rem;
    margin-bottom: .3rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
}

.in-progress-nav-icon {
    font-size: 0.7rem;
}

.in-progress-nav-toggle-icon {
    font-size: 0.72rem;
    transition: transform 0.2s ease;
    margin-left: auto;
}

.in-progress-nav-section.collapsed .in-progress-nav-toggle-icon {
    transform: rotate(-90deg);
}

.in-progress-nav-section.collapsed > .nav-item {
    display: none !important;
}

.sidebar.retracted .in-progress-nav-section.collapsed > .nav-item {
    display: flex !important;
}

.sidebar.retracted .in-progress-nav-title {
    display: none;
}

.main-wrapper {
    flex: 1;
    margin-left: calc(var(--sidebar-width) + 15px);
    padding: 15px;
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar.retracted + .main-wrapper {
    margin-left: calc(var(--sidebar-collapsed-width) + 15px);
}

/* Adjust top nav for sidebar layout */
.top-bar {
    height: 70px;
    background-color: var(--nav-bg);
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s, border-radius 0.3s;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    position: sticky;
    top: 15px;
    z-index: 900;
}

.top-bar-clinic-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

.top-bar-clinic-brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--input-border));
    color: var(--primary);
    flex-shrink: 0;
}

.top-bar-clinic-brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.top-bar-clinic-name {
    color: var(--text-title);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 32vw;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-logout {
    padding: 0.6rem 1.2rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.btn-logout:hover {
    background-color: var(--primary-dark);
}

.theme-toggle-nav {
    background: none;
    border: 1.5px solid var(--text-main);
    color: var(--text-main);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    margin-right: 0.5rem;
    text-decoration: none;
}

.theme-toggle-nav:hover {
    background-color: var(--primary);
    color: var(--white);
}

/* User Avatar */
.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    background-color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: default;
}

/* Bottom Navigation for Mobile */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 15px;
    left: 15px;
    right: 15px;
    background-color: var(--bg-card);
    height: 70px;
    border-radius: 15px;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
}

.bottom-nav .nav-item {
    flex-direction: column;
    padding: 0.5rem;
    gap: 4px;
    font-size: 0.75rem;
    background: none;
    color: var(--text-muted);
}

.bottom-nav .nav-item.active {
    background: none;
    color: var(--primary);
}

.bottom-nav .nav-icon {
    font-size: 1.3rem;
    min-width: auto;
}

.bottom-nav .nav-text {
    margin-left: 0;
    font-weight: 600;
}

.bottom-nav-more {
    position: relative;
}

.bottom-nav-toggle {
    border: none;
    background: none;
    width: 100%;
}

.bottom-nav-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    min-width: 180px;
    padding: 0.5rem;
    border-radius: 14px;
    border: 1px solid var(--input-border);
    background-color: var(--bg-card);
    box-shadow: 0 10px 24px rgba(0,0,0,0.14);
    display: none;
    flex-direction: column;
    gap: 0.35rem;
    max-height: min(60vh, calc(100vh - 130px - env(safe-area-inset-bottom)));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.bottom-nav-menu::-webkit-scrollbar {
    width: 6px;
}

.bottom-nav-menu::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--text-muted) 65%, #8b95aa);
    border-radius: 999px;
}

.bottom-nav-more.open .bottom-nav-menu {
    display: flex;
}

.bottom-nav-menu .nav-item {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 0.9rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.bottom-nav-menu .nav-icon {
    width: 20px;
    font-size: 1rem;
}

.bottom-nav-menu .nav-text {
    display: inline;
    margin-left: 0;
}

.bottom-nav-admin-section {
    margin-top: 0.25rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--input-border);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.bottom-nav-section-title {
    padding: 0.25rem 0.9rem 0.15rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Responsive Layout */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-wrapper {
        margin-left: 0;
        padding-bottom: calc(130px + env(safe-area-inset-bottom)); /* Space for floating bottom nav + safe area */
    }

    .sidebar.retracted + .main-wrapper,
    html.pre-sidebar-retracted .sidebar + .main-wrapper {
        margin-left: 0;
    }

    .bottom-nav {
        display: flex;
    }

    .bottom-nav-more {
        display: flex;
        align-items: center;
    }

    .top-bar {
        padding: 0.5rem 0.85rem;
        min-height: 60px;
        height: auto;
        position: static;
    }

    .top-bar-clinic-name {
        display: none;
    }

    .user-info {
        margin-left: auto;
        gap: 0.45rem;
        flex-wrap: wrap;
        justify-content: flex-end;
        min-width: 0;
    }

    .user-info-wrapper {
        min-width: 0;
    }

    .user-info #userName {
        display: none; /* Hide user name on very small screens if needed */
    }

    .theme-toggle-nav,
    .notification-bell {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        margin-right: 0;
    }

    .notification-container {
        margin-right: 0;
    }

    .btn-logout {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        gap: 0;
        justify-content: center;
        font-size: 0;
    }

    .btn-logout i {
        margin: 0;
        font-size: 1rem;
    }

    /* Cards responsiveness */
    .stats {
        grid-template-columns: 1fr 1fr;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-group {
        width: 100%;
    }

    .btn-group .btn-primary {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .stats {
        grid-template-columns: 1fr;
    }
    
    .top-bar .user-info {
        gap: 0.5rem;
    }
}


/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-card);
    padding: 2rem;
    border-radius: 15px;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(-20px);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-content h3 {
    color: var(--text-title);
    margin-top: 0;
    margin-bottom: 1rem;
}

.modal-content p {
    color: var(--text-main);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-input-container {
    margin-bottom: 1.5rem;
}

.quick-specialty-modal-fields {
    display: grid;
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.quick-specialty-modal-fields label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.quick-specialty-modal-error {
    margin: 0 0 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.modal-actions button {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
    padding: 0.75rem 1rem;
}

.modal-content-danger {
    border: 2px solid var(--feedback-error-border);
}

.modal-danger-icon {
    display: block;
    text-align: center;
    font-size: 2.5rem;
    color: var(--feedback-error-text);
    margin-bottom: 1rem;
}

.btn-confirm-danger {
    background-color: var(--feedback-error-text) !important;
    border-color: var(--feedback-error-text) !important;
    color: #fff !important;
}

.btn-confirm-danger:hover {
    opacity: 0.85;
}

@media (max-width: 480px) {
    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions button {
        width: 100%;
    }
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.search-result-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--input-border);
}

.search-result-item:hover {
    background: var(--bg-body);
    color: var(--primary);
}

.selected-patient-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--primary-light);
    color: var(--text-main);
    border-radius: 8px;
    width: fit-content;
    margin-top: 10px;
}

.btn-icon {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.btn-icon:hover {
    opacity: 0.7;
}


/* Notification Center */
.notification-container {
    position: relative;
    margin-right: 15px;
}

.notification-bell {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    position: relative;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-bell:hover {
    background: var(--bg-body);
    color: var(--primary);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #f44336;
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-card);
}

.notification-panel {
    position: absolute;
    top: 100%;
    right: 0;
    width: 350px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    margin-top: 10px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--input-border);
    animation: slideDown 0.3s ease;
}

.notification-panel.active {
    display: flex;
}

.notification-header {
    padding: 15px;
    border-bottom: 1px solid var(--input-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-title);
    display: flex;
    align-items: center;
    gap: 8px;
}

.notification-count {
    background: var(--bg-body);
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--text-muted);
}

.notification-actions {
    padding: 8px 15px;
    border-bottom: 1px solid var(--input-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-body);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

.notification-ttl-config {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.notification-ttl-config input {
    width: 45px;
    padding: 2px 4px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.8rem;
}

.notification-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 15px;
    border-bottom: 1px solid var(--input-border);
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notification-item:hover {
    background: var(--bg-body);
}

.notification-item.unread {
    background: rgba(var(--primary-rgb, 58, 123, 213), 0.05);
}

.notification-item.unread::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
}

.notification-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-title);
    padding-right: 20px;
}

.notification-item-message {
    font-size: 0.88rem;
    color: var(--text-main);
    line-height: 1.4;
}

.notification-item-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Spec 31 §23 Fase A3 — ações Pix na entrada do painel */
.notification-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.notification-item-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--input-border);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.notification-item-action:hover {
    background: var(--bg-body);
    border-color: var(--primary);
    color: var(--primary);
}

.notification-item-action:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.notification-item-action--copy {
    background: rgba(var(--primary-rgb, 58, 123, 213), 0.08);
    border-color: rgba(var(--primary-rgb, 58, 123, 213), 0.35);
    color: var(--primary);
}

.notification-item-action--copy:hover {
    background: rgba(var(--primary-rgb, 58, 123, 213), 0.18);
}

.notification-item-action i {
    font-size: 0.85rem;
}

.notification-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.notification-empty i {
    display: block;
    font-size: 2rem;
    margin-bottom: 10px;
    opacity: 0.3;
}

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

@media (max-width: 480px) {
    .notification-panel {
        position: fixed;
        top: 60px;
        left: 10px;
        right: 10px;
        width: calc(100% - 20px);
    }
}
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    color: var(--text-main);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 450px;
    animation: toastSlideIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border-left: 6px solid var(--primary);
}

.toast.success { border-left-color: #4caf50; }
.toast.info { border-left-color: var(--primary); }
.toast.warning { border-left-color: #ff9800; }
.toast.error { border-left-color: #f44336; }

.toast-content { flex: 1; }
.toast-title { font-weight: 700; margin-bottom: 2px; display: block; color: var(--text-title); }
.toast-message { font-size: 0.88rem; line-height: 1.4; }

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toast-close:hover {
    color: var(--text-main);
}

@keyframes toastSlideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastFadeOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50%); }
}

.feedback-toast-container {
    position: fixed;
    left: 50%;
    bottom: max(1rem, calc(env(safe-area-inset-bottom) + 1rem));
    transform: translateX(-50%);
    width: min(calc(100vw - 2rem), 32rem);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    z-index: 10050;
    pointer-events: none;
}

.feedback-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--input-border);
    box-shadow: var(--feedback-shadow);
    color: var(--text-main);
    background: var(--bg-card);
    transform-origin: center bottom;
    animation: feedbackToastIn 0.24s ease-out both;
}

.feedback-toast-text {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
}

.feedback-toast.feedback-toast-success {
    background: var(--feedback-success-bg);
    border-color: var(--feedback-success-border);
    color: var(--feedback-success-text);
}

.feedback-toast.feedback-toast-error {
    background: var(--feedback-error-bg);
    border-color: var(--feedback-error-border);
    color: var(--feedback-error-text);
}

.feedback-toast.feedback-toast-info {
    background: var(--feedback-info-bg);
    border-color: var(--feedback-info-border);
    color: var(--feedback-info-text);
}

.feedback-toast.feedback-toast-warning {
    background: var(--feedback-warning-bg);
    border-color: var(--feedback-warning-border);
    color: var(--feedback-warning-text);
}

.feedback-toast-close {
    border: none;
    background: transparent;
    color: inherit;
    width: 32px;
    min-width: 32px;
    height: 32px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    opacity: 0.78;
}

.feedback-toast-close:hover {
    opacity: 1;
    background: color-mix(in srgb, currentColor 18%, transparent);
}

.feedback-toast.feedback-toast-leave {
    animation: feedbackToastOut 0.2s ease-in forwards;
}

@keyframes feedbackToastIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes feedbackToastOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(34px);
    }
}

@media (max-width: 768px) {
    .feedback-toast-container {
        width: calc(100vw - 1.2rem);
        bottom: max(0.8rem, calc(env(safe-area-inset-bottom) + 0.8rem));
    }

    .feedback-toast {
        padding: 0.8rem 0.9rem;
    }

    .feedback-toast-text {
        font-size: 0.9rem;
    }
}
