* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f3f5f7;
    color: #333;
}

button, input, select, textarea {
    font: inherit;
}

.agenda-app {
    width: 100%;
    min-height: 100vh;
    background: #fff;
}

.agenda-toolbar {
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 8px 15px;
    border-bottom: 1px solid #d8dde2;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
}

.toolbar-left,
.toolbar-center {
    display: flex;
    align-items: center;
    gap: 5px;
}

.toolbar-left {
    min-width: 310px;
}

.toolbar-left h1 {
    margin: 0 0 0 10px;
    font-size: 19px;
    font-weight: 600;
}

.btn {
    border: 1px solid #cbd2d8;
    border-radius: 3px;
    padding: 8px 13px;
    background: #fff;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(.96);
}

.btn-light {
    background: #fff;
    color: #555;
}

.btn-primary {
    border-color: #0788c9;
    background: #0788c9;
    color: #fff;
}

.btn-danger {
    border-color: #d9534f;
    background: #d9534f;
    color: #fff;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 24px;
    line-height: 1;
}

.view-btn {
    border: 1px solid #168bc4;
    background: #fff;
    color: #168bc4;
    padding: 8px 13px;
    cursor: pointer;
}

.view-btn:first-child {
    border-radius: 3px 0 0 3px;
}

.view-btn:last-child {
    border-radius: 0 3px 3px 0;
}

.view-btn.active {
    background: #168bc4;
    color: #fff;
}

.calendar-container {
    overflow: auto;
    height: calc(100vh - 62px);
}

.week-calendar {
    min-width: 900px;
}

.week-header {
    display: grid;
    grid-template-columns: 65px repeat(7, minmax(115px, 1fr));
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
}

.week-header > div {
    border-right: 1px solid #e1e5e8;
    border-bottom: 1px solid #e1e5e8;
    min-height: 54px;
    padding: 7px;
    text-align: center;
}

.week-header .time-corner {
    background: #f7f8f9;
}

.day-header {
    font-size: 12px;
    color: #777;
}

.day-header strong {
    display: block;
    margin-top: 4px;
    font-size: 17px;
    color: #333;
}

.day-header.today {
    background: #eef8fd;
}

.day-header.today strong {
    color: #0788c9;
}

.week-body {
    display: grid;
    grid-template-columns: 65px repeat(7, minmax(115px, 1fr));
}

.time-column {
    background: #fafbfc;
}

.time-slot {
    height: 60px;
    border-right: 1px solid #e1e5e8;
    border-bottom: 1px solid #e1e5e8;
    color: #777;
    font-size: 11px;
    padding: 4px;
    text-align: right;
}

.day-column {
    position: relative;
    border-right: 1px solid #e1e5e8;
}

.hour-cell {
    height: 60px;
    border-bottom: 1px solid #e1e5e8;
    position: relative;
}

.hour-cell:hover {
    background: #f7fbfd;
}

.appointment {
    position: absolute;
    left: 4px;
    right: 4px;
    min-height: 30px;
    padding: 5px 7px;
    border-radius: 2px;
    color: #fff;
    cursor: grab;
    overflow: hidden;
    z-index: 5;
    box-shadow: 0 1px 2px rgba(0,0,0,.15);
    font-size: 11px;
}

.appointment:active {
    cursor: grabbing;
}

.appointment .appointment-time {
    font-weight: bold;
    font-size: 10px;
}

.appointment .appointment-name {
    margin-top: 3px;
    font-weight: bold;
}

.appointment .appointment-type {
    margin-top: 2px;
    opacity: .9;
}

.calendar-month {
    padding: 15px;
}

.month-title {
    text-align: center;
    font-size: 20px;
    margin: 5px 0 15px;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-top: 1px solid #ddd;
    border-left: 1px solid #ddd;
}

.month-weekday,
.month-day {
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

.month-weekday {
    padding: 9px;
    text-align: center;
    background: #f5f6f7;
    font-size: 12px;
    font-weight: bold;
}

.month-day {
    min-height: 125px;
    padding: 6px;
}

.month-day-number {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.month-day.today {
    background: #eef8fd;
}

.month-event {
    padding: 4px 5px;
    margin: 3px 0;
    border-radius: 2px;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.day-view {
    min-width: 500px;
}

.day-view .day-column-single {
    position: relative;
}

.hidden {
    display: none !important;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-cita {
    width: min(520px, calc(100vw - 30px));
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 10px 35px rgba(0,0,0,.3);
}

.modal-header {
    background: #0788c9;
    color: #fff;
    min-height: 62px;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-weight: bold;
}

.modal-periodo {
    font-size: 12px;
    margin-top: 4px;
    opacity: .9;
}

.btn-close {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
}

.modal-body {
    padding: 18px;
}

.modal-body label {
    display: block;
    font-size: 12px;
    color: #555;
    margin: 0 0 5px;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
    width: 100%;
    border: 1px solid #cdd3d8;
    border-radius: 3px;
    padding: 9px;
    margin-bottom: 12px;
}

.patient-row {
    display: flex;
    gap: 5px;
}

.patient-row input {
    flex: 1;
}

.patient-row button {
    width: 45px;
    height: 38px;
    padding: 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid #e0e3e5;
    display: flex;
    justify-content: space-between;
}

.footer-right {
    display: flex;
    gap: 8px;
}

@media (max-width: 850px) {
    .agenda-toolbar {
        flex-wrap: wrap;
        height: auto;
    }

    .toolbar-left {
        min-width: 0;
    }

    .toolbar-center {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .calendar-container {
        height: calc(100vh - 115px);
    }
}
