/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header styles */
header {
    text-align: center;
    margin-bottom: 1.5rem;
}

h1 {
    color: #2c3e50;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Status bar - now positioned below calendars */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    margin-top: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    margin-right: 15px;
}

.update-actions {
    display: flex;
    align-items: center;
}

.refresh-button {
    display: flex;
    align-items: center;
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.refresh-button:hover {
    background-color: #2980b9;
}

.refresh-button:active {
    transform: scale(0.98);
}

.refresh-button.loading {
    background-color: #7f8c8d;
    cursor: not-allowed;
}

.refresh-icon {
    margin-right: 6px;
}

.refresh-button.loading .refresh-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pulse {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
    background-color: #6c757d;
}

.pulse.online {
    background-color: #28a745;
    animation: pulse 2s infinite;
}

.pulse.error {
    background-color: #dc3545;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.last-update {
    font-size: 0.9rem;
    color: #6c757d;
}

/* Calendar container */
.calendars-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 1rem;
}

/* Calendar styles */
.calendar-box {
    flex: 1;
    min-width: 320px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.calendar-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.plasma-header {
    background-color: #3498db;
    color: white;
}

.blood-header {
    background-color: #e74c3c;
    color: white;
}

.calendar-title {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    font-weight: 600;
}

.counts-badge {
    background-color: rgba(255, 255, 255, 0.3);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.icon {
    margin-right: 0.5rem;
    width: 24px;
    height: 24px;
}

.calendar-content {
    padding: 1rem;
}

/* Month navigation */
.month-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.month-display {
    font-weight: 600;
    font-size: 1.1rem;
    text-align: center;
    flex-grow: 1;
}

.nav-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid #ddd;
    background-color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-button:hover {
    background-color: #f5f5f5;
    border-color: #aaa;
}

.nav-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Filter styles */
.month-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.hidden {
    display: none;
}

/* Color scale info */
.color-scale-info {
    margin-bottom: 1rem;
    padding: 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.plasma-scale {
    background-color: #eaf2f8;
}

.blood-scale {
    background-color: #fdedec;
}

.color-scale-label {
    margin-bottom: 5px;
    font-weight: 600;
}

.color-scale {
    display: flex;
    justify-content: space-between;
}

.color-item {
    display: flex;
    align-items: center;
}

.color-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 4px;
}

/* Loading indicator */
.loading {
    padding: 2rem;
    text-align: center;
}

.progress-bar {
    height: 4px;
    background-color: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar-inner {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    animation: loading 1.5s infinite ease-in-out;
}

.plasma-progress {
    background-color: #3498db;
}

.blood-progress {
    background-color: #e74c3c;
}

@keyframes loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Calendar grid */
.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}

.weekday {
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: #7f8c8d;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.day-cell {
    aspect-ratio: 1/1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
}

.day-cell:hover {
    transform: scale(1.05);
    transition: transform 0.2s;
    z-index: 1;
}

.day-empty {
    background-color: transparent;
}

.day-number {
    font-weight: 600;
    font-size: 0.9rem;
}

.slot-count {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Heat map colors for plasma - improved scale */
.plasma-day-0 { background-color: #f5f7fa; }
.plasma-day-1, .plasma-day-2 { background-color: #d6eaf8; }
.plasma-day-3, .plasma-day-4, .plasma-day-5, .plasma-day-6, .plasma-day-7, .plasma-day-8, .plasma-day-9 { background-color: #85c1e9; }
.plasma-day-10, .plasma-day-11, .plasma-day-12, .plasma-day-13, .plasma-day-14, .plasma-day-15, 
.plasma-day-16, .plasma-day-17, .plasma-day-18, .plasma-day-19 { background-color: #3498db; color: white; }
.plasma-day-20, .plasma-day-30, .plasma-day-40, .plasma-day-50, .plasma-day-60, 
.plasma-day-70, .plasma-day-80, .plasma-day-90, .plasma-day-100 { background-color: #2874a6; color: white; }

/* Heat map colors for blood - improved scale */
.blood-day-0 { background-color: #f5f7fa; }
.blood-day-1, .blood-day-2 { background-color: #fadbd8; }
.blood-day-3, .blood-day-4, .blood-day-5, .blood-day-6, .blood-day-7, .blood-day-8, .blood-day-9 { background-color: #f1948a; }
.blood-day-10, .blood-day-11, .blood-day-12, .blood-day-13, .blood-day-14, .blood-day-15, 
.blood-day-16, .blood-day-17, .blood-day-18, .blood-day-19, .blood-day-20, .blood-day-21, 
.blood-day-22, .blood-day-23, .blood-day-24, .blood-day-25, .blood-day-26, .blood-day-27, 
.blood-day-28, .blood-day-29 { background-color: #e74c3c; color: white; }
.blood-day-30, .blood-day-40, .blood-day-50, .blood-day-60, .blood-day-70, .blood-day-80, 
.blood-day-90, .blood-day-100 { background-color: #b03a2e; color: white; }

/* Tooltip */
.tooltip {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translate(-50%, -100%);
    background-color: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 10;
    width: max-content;
    max-width: 250px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #2c3e50;
}

.day-cell:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* Day detail modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 1.5rem;
    position: relative;
}

.close-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7f8c8d;
}

.close-button:hover {
    color: #2c3e50;
}

.modal-title {
    margin-bottom: 1rem;
    color: #2c3e50;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.time-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 1rem;
}

.time-slot {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.plasma-slot {
    background-color: #ebf5fb;
    border: 1px solid #aed6f1;
}

.blood-slot {
    background-color: #fdedec;
    border: 1px solid #f5b7b1;
}

.clock-icon {
    margin-right: 0.5rem;
    width: 16px;
    height: 16px;
}

/* Error state */
.error-message {
    padding: 1rem;
    background-color: #f8d7da;
    color: #721c24;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    display: none;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 2rem;
    color: #7f8c8d;
    font-size: 0.8rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

/* Current day highlight */
.today {
    border: 2px solid #28a745;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .calendars-container {
        flex-direction: column;
    }
    
    .calendar-box {
        width: 100%;
    }
    
    .status-bar {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .status-indicator {
        margin-bottom: 0;
        margin-right: 0;
        justify-content: center;
    }
    
    .update-actions {
        margin: 5px 0;
    }
}