* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
}

#app { padding: 12px; }

header {
    text-align: center;
    padding: 8px 0 12px;
}

header h1 {
    font-size: 20px;
    color: #2e7d32;
}

.hidden { display: none !important; }

/* Chips */
.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 12px;
    -webkit-overflow-scrolling: touch;
}

.chip {
    flex-shrink: 0;
    padding: 8px 20px;
    border-radius: 20px;
    background: #e0e0e0;
    font-size: 15px;
    cursor: pointer;
    border: none;
    transition: background 0.2s, color 0.2s;
}

.chip.active {
    background: #4CAF50;
    color: white;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.grid-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    font-size: 14px;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.grid-item:active {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Back button */
.back-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: #2e7d32;
    cursor: pointer;
    padding: 4px 0 12px;
}

h2 {
    font-size: 17px;
    margin-bottom: 12px;
}

/* Doctor cards */
.doctor-card {
    background: white;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 8px;
    border-left: 4px solid #e0e0e0;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.doctor-card:active {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.doctor-card.preferred {
    border-left-color: #4CAF50;
}

.doctor-card.no-slots {
    opacity: 0.5;
}

.doctor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.doctor-name {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
}

.rating-badge {
    margin-right: 4px;
}

.rating-buttons {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.rating-btn {
    background: #f0f0f0;
    border: none;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.rating-btn.active {
    opacity: 1;
    background: #e8f5e9;
}

.rating-btn:hover {
    opacity: 0.8;
}

.doctor-filial {
    font-size: 12px;
    color: #666;
    margin: 3px 0;
}

.doctor-slot {
    font-size: 13px;
    color: #4CAF50;
    font-weight: 500;
}

.doctor-slot.none {
    color: #999;
}

.expand-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    background: white;
    border: 1px dashed #aaa;
    border-radius: 10px;
    color: #666;
    font-size: 14px;
    cursor: pointer;
}

/* Schedule */
#schedule-header {
    margin-bottom: 16px;
}

.schedule-doctor-name {
    font-size: 17px;
    font-weight: 600;
}

.schedule-meta {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
}

.filial-group {
    margin-bottom: 20px;
    padding: 12px;
    background: white;
    border-radius: 10px;
}

.filial-title {
    font-size: 14px;
    font-weight: 600;
    color: #2e7d32;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e8f5e9;
}

.day-group {
    margin-bottom: 16px;
}

.day-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.slots-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.slot {
    background: #e8f5e9;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.slot:active {
    background: #4CAF50;
    color: white;
}

/* Loading */
.inline-loader {
    display: flex;
    justify-content: center;
    padding: 40px 0;
}

#loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #4CAF50;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
#error {
    text-align: center;
    padding: 40px 20px;
}

#error p {
    color: #c62828;
    margin-bottom: 12px;
}

#error button {
    padding: 8px 20px;
    border: 1px solid #c62828;
    background: white;
    color: #c62828;
    border-radius: 6px;
    cursor: pointer;
}

/* Bookings */
.bookings-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2e7d32;
}

.booking-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-left: 4px solid #2e7d32;
}

.booking-doctor {
    font-weight: 600;
    font-size: 14px;
}

.booking-detail {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.booking-right {
    text-align: right;
    flex-shrink: 0;
}

.booking-date {
    font-size: 14px;
    font-weight: 600;
    color: #2e7d32;
}

.booking-time {
    font-size: 18px;
    font-weight: 700;
    color: #2e7d32;
}

.booking-cancel {
    margin-top: 6px;
    background: none;
    border: 1px solid #c62828;
    color: #c62828;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11px;
    cursor: pointer;
}

.fav-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
}

.fav-filter input {
    width: 18px;
    height: 18px;
    accent-color: #4CAF50;
}

#bookings-section {
    margin-bottom: 16px;
}

/* Modal */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s;
}

#modal {
    background: white;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 480px;
    padding: 20px 20px 28px;
    animation: slideUp 0.25s ease-out;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(100%) } to { transform: translateY(0) } }

.modal-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.modal-info {
    background: #f5f5f5;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
}

.modal-info-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

.modal-info-label {
    color: #888;
}

.modal-info-value {
    font-weight: 500;
    text-align: right;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-btn {
    flex: 1;
    padding: 14px;
    border-radius: 10px;
    border: none;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
}

.modal-btn.cancel {
    background: #f0f0f0;
    color: #333;
}

.modal-btn.confirm {
    background: #4CAF50;
    color: white;
}

.modal-btn.confirm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.modal-btn.confirm .spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

.modal-result {
    text-align: center;
    padding: 8px 0;
    font-size: 15px;
}

.modal-result.success {
    color: #2e7d32;
}

.modal-result.error {
    color: #c62828;
}
