/* Layout geral */
.dashboard-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 34px auto 56px;
    max-width: 100%;
}

.dashboard-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-header h1 {
    margin: 4px 0 6px;
    color: var(--blue-dark);
    font-size: 34px;
}

.dashboard-header p {
    margin: 0;
    color: var(--muted);
}

.dashboard-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(260px, 330px) 1fr;
    gap: 22px;
}

.panel {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    margin: 0;
    color: var(--blue-dark);
    font-size: 21px;
}

.panel-header p {
    margin: 4px 0 0;
    color: var(--muted);
}

.counter {
    min-width: 34px;
    padding: 4px 8px;
    border-radius: 999px;
    color: var(--blue-dark);
    background: #EAF2FF;
    text-align: center;
    font-weight: 800;
}

.search-box {
    padding: 14px 18px 0;
}

.search-box input,
.agenda-toolbar input {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.patient-list {
    display: grid;
    gap: 8px;
    max-height: 500px;
    margin: 0;
    padding: 14px 18px 18px;
    overflow: auto;
    list-style: none;
}

.patient-list li {
    display: grid;
    gap: 2px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.patient-list span {
    color: var(--muted);
    font-size: 14px;
}

.patient-row-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: start;
    gap: 10px;
}

.patient-row-main > div:first-child {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    min-height: 26px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status-badge.is-active {
    color: #155B38;
    background: #E6F6EE;
}

.status-badge.is-inactive {
    color: #7A3141;
    background: #FCE8EC;
}

.patient-actions-menu {
    position: relative;
}

.icon-menu-button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--blue-dark);
    cursor: pointer;
    font-weight: 900;
}

.patient-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 5;
    display: grid;
    min-width: 136px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.patient-menu[hidden] {
    display: none;
}

.patient-menu button {
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    font: inherit;
}

.patient-menu button:hover,
.patient-menu button:focus-visible {
    background: #F2F7FF;
    outline: none;
}

.patient-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 18px 18px;
    color: var(--muted);
    font-size: 13px;
}

.patient-pagination .button {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 13px;
}

.patient-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.form-field-wide {
    grid-column: 1 / -1;
}

.form-field textarea {
    width: 100%;
    resize: vertical;
}

.recurring-option span {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.recurring-option input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
}

.recurring-option small:first-of-type {
    color: var(--muted);
    font-weight: 500;
}

.badge-recurring {
    color: #245C2F;
    background: #E8F6EA;
    border: 1px solid #B8E2BF;
}

.patient-form-grid .form-field {
    min-width: 0;
}

.patient-form-grid input,
.patient-form-grid select,
.patient-form-grid textarea {
    min-width: 0;
}

.patient-form-grid small {
    min-height: 18px;
}

.agenda-toolbar {
    align-items: flex-start;
}

.agenda-toolbar input {
    max-width: 180px;
}

/* Resumo da semana */
.week-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.weekdays-grid {
    padding: 18px;
}

.week-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 0;
    color: var(--text);
}

.summary-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid #CFE0F7;
    border-radius: 999px;
    background: #F2F7FF;
    color: var(--blue-dark);
    font-size: 13px;
    font-weight: 750;
}

.summary-item strong {
    color: var(--blue-dark);
}

/* Grid da semana */
.weekdays-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

/* Card do dia */
.week-day-card {
    position: relative;
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
    max-width: 100%;
    min-height: 126px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.week-day-card.day-color-0 {
    background: #F4F8FF;
}

.week-day-card.day-color-1 {
    background: #F2FBF6;
}

.week-day-card.day-color-2 {
    background: #F8F5FF;
}

.week-day-card.day-color-3 {
    background: #FFFBEA;
}

.week-day-card.day-color-4 {
    background: #FFF5F7;
}

.week-day-card.day-color-5 {
    background: #F4F7FA;
}

.week-day-card.day-has-appointments {
    border: 2px solid rgba(47, 107, 203, 0.72);
    box-shadow: 0 10px 20px rgba(31, 83, 151, 0.12);
}

.week-day-card.day-empty {
    border-style: dashed;
    background: #FBFCFE;
    box-shadow: none;
}

.week-day-card:hover,
.week-day-card:focus-visible {
    border-color: var(--blue);
    box-shadow: 0 8px 18px rgba(31, 50, 72, 0.12);
    outline: none;
    transform: translateY(-1px);
}

.week-day-card.is-today {
    border-color: var(--blue);
    box-shadow: inset 0 0 0 1px var(--blue);
}

.week-day-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-right: 28px;
}

.week-day-header strong {
    color: var(--blue-dark);
    font-size: 16px;
}

.week-day-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--blue-dark);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(216, 224, 234, 0.9);
    font-weight: 900;
}

/* Badge de notificacao */
.day-notification-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    border-radius: 999px;
    color: #fff;
    background: var(--blue);
    box-shadow: 0 6px 14px rgba(53, 111, 214, 0.26);
    font-size: 13px;
    font-weight: 900;
}

/* Corpo do card do dia */
.week-day-body {
    display: grid;
    align-content: end;
    gap: 8px;
    min-width: 0;
    padding-top: 18px;
}

.week-day-status {
    display: block;
    color: var(--text);
    font-size: 15px;
    font-weight: 900;
    overflow-wrap: break-word;
}

.day-empty .week-day-status {
    color: var(--muted);
    font-weight: 750;
}

.week-day-first-time {
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

/* Cards de agendamento */
.appointments-list {
    display: grid;
    gap: 10px;
    padding: 18px;
}

.appointment-row {
    display: grid;
    grid-template-columns: 108px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.day-appointments-list {
    display: grid;
    gap: 12px;
    max-height: min(62vh, 520px);
    overflow-y: auto;
    padding-right: 4px;
}

.day-appointment-card {
    margin: 0;
}

.appointment-datetime {
    color: var(--blue-dark);
    font-weight: 900;
}

.appointment-patient {
    display: grid;
    min-width: 0;
}

.appointment-patient strong,
.appointment-patient span {
    overflow-wrap: anywhere;
}

.appointment-patient span {
    color: var(--muted);
}

.appointment-time {
    color: var(--blue-dark);
    font-weight: 900;
}

.appointment-main strong {
    display: block;
}

.appointment-main span {
    color: var(--muted);
}

.appointment-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.empty-state {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

/* Responsividade */
@media (max-width: 900px) {
    .dashboard-header,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .appointment-row {
        grid-template-columns: 1fr;
    }

    .appointment-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .dashboard-shell {
        width: min(100% - 20px, 1180px);
        margin: 18px auto 34px;
    }

    .dashboard-header h1 {
        font-size: 28px;
    }

    .dashboard-actions,
    .week-controls {
        width: 100%;
    }

    .dashboard-actions .button,
    .week-controls .button,
    .week-controls input {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .agenda-toolbar {
        gap: 16px;
    }

    .weekdays-grid {
        padding: 12px;
    }

    .weekdays-list {
        grid-template-columns: 1fr;
    }

    .week-day-card {
        width: 100%;
        min-height: 118px;
    }

    .week-day-header {
        align-items: center;
    }

    .patient-list {
        max-height: 360px;
    }

    .patient-row-main {
        grid-template-columns: 1fr auto;
    }

    .patient-actions-menu {
        grid-column: 2;
        grid-row: 1;
    }

    .status-badge {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .patient-form-grid {
        grid-template-columns: 1fr;
    }

    .day-appointments-list {
        max-height: calc(100dvh - 230px);
    }

    .appointment-row {
        gap: 10px;
        padding: 12px;
    }

    .appointment-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .appointment-actions .badge {
        justify-content: center;
        width: 100%;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .dashboard-shell {
        width: calc(100% - 12px);
        margin-top: 12px;
    }

    .dashboard-header h1 {
        font-size: 24px;
    }

    .panel-header,
    .search-box,
    .patient-list,
    .weekdays-grid,
    .appointments-list {
        padding-left: 12px;
        padding-right: 12px;
    }

    .appointment-actions {
        grid-template-columns: 1fr;
    }
}
