/* WP Outlook Calendar Styles */
.wp-outlook-calendar {
    max-width: 800px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

/* Calendar Header */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.calendar-title {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
    color: #333;
    flex-grow: 1;
    text-align: center;
}

.calendar-nav {
    background: #007cba;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s ease;
    min-width: 40px;
}

.calendar-nav:hover {
    background: #005a87;
}

.calendar-nav:active {
    background: #004a73;
}

.calendar-nav:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Loading State */
.calendar-loading {
    padding: 40px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Calendar Content */
.calendar-content {
    padding: 0;
}

.calendar-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.calendar-table th {
    background: #f1f1f1;
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    color: #555;
    border-bottom: 1px solid #ddd;
    font-size: 0.9em;
}

/* Day number cells (first row of each week) */
.calendar-day-number {
    width: 14.28%;
    height: 20px;
    vertical-align: middle;
    border: 1px solid #eee;
    border-bottom: none;
    padding: 8px;
    text-align: center;
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
}

.calendar-day-number.empty {
    background: #f9f9f9;
}

.calendar-day-number.today {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
    font-weight: bold;
}

/* Day content cells (second row of each week) */
.calendar-day-content {
    width: 14.28%;
    height: 80px;
    vertical-align: middle;
    border: 1px solid #eee;
    border-top: none;
    padding: 8px;
    background: #fff;
    cursor: default;
    text-align: center;
    font-size: 0.85em;
    line-height: 1.3;
}

.calendar-day-content.empty {
    background: #f9f9f9;
}

.calendar-day-content.has-events {
    background: #f0f8ff;
    color: #007cba;
    font-weight: 500;
    overflow: hidden;
}

.calendar-day-content.multi-day-event {
    background: #e8f5e8;
    color: #28a745;
    font-weight: 500;
}

.calendar-day-content.today {
    background: #fff8e1;
    border-color: #ffc107;
}

.calendar-day-content.today.has-events {
    background: #fff3cd;
    color: #856404;
}

.calendar-day-content.today.multi-day-event {
    background: #f0f8d0;
    color: #1e7e34;
}

.day-events.expanded {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #007cba;
    border-radius: 4px;
    margin: 2px;
    z-index: 10;
    position: relative;
}

.event {
    background: #007cba;
    color: white;
    padding: 2px 6px;
    margin: 1px 0;
    border-radius: 3px;
    font-size: 0.75em;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.event:hover {
    background: #005a87;
}

/* Multi-day event styles */
.event.multi-day {
    background: #28a745;
    position: relative;
}

.event.multi-day:hover {
    background: #1e7e34;
}

.event.multi-day::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 4px solid #28a745;
}

.event.multi-day::after {
    content: '';
    position: absolute;
    right: -2px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-right: 4px solid #28a745;
}

/* Start day indicator */
.event.multi-day.start-day::before {
    border-left-color: #1e7e34;
}

/* End day indicator */
.event.multi-day.end-day::after {
    border-right-color: #1e7e34;
}

/* Middle day (neither start nor end) */
.event.multi-day:not(.start-day):not(.end-day) {
    border-radius: 0;
    margin-left: -1px;
    margin-right: -1px;
}

/* Start day styling */
.event.multi-day.start-day {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    margin-right: -1px;
}

/* End day styling */
.event.multi-day.end-day {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    margin-left: -1px;
}

.day-events.expanded .event {
    white-space: normal;
    word-wrap: break-word;
    margin: 3px 0;
    padding: 4px 8px;
    font-size: 0.8em;
}

/* Error State */
.calendar-error {
    padding: 20px;
    text-align: center;
    color: #d63638;
    background: #ffeaea;
    border: 1px solid #f0a0a0;
    border-radius: 4px;
    margin: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wp-outlook-calendar {
        margin: 10px;
        border-radius: 4px;
    }
    
    .calendar-header {
        padding: 10px 15px;
    }
    
    .calendar-title {
        font-size: 1.2em;
    }
    
    .calendar-nav {
        padding: 6px 10px;
        font-size: 14px;
        min-width: 35px;
    }
    
    .calendar-day {
        height: 40px;
    }
    
    .calendar-table th {
        padding: 8px 4px;
        font-size: 0.8em;
    }
    
    .day-number {
        font-size: 0.8em;
        top: 3px;
        left: 5px;
    }
    
    .day-events {
        padding: 15px 3px 3px 3px;
        max-height: 60px;
    }
    
    .event {
        font-size: 0.7em;
        padding: 1px 4px;
    }
}

@media (max-width: 480px) {
    .calendar-day {
        height: 60px;
    }
    
    .day-events {
        padding: 12px 2px 2px 2px;
        max-height: 45px;
    }
    
    .event {
        font-size: 0.65em;
        padding: 1px 3px;
        margin: 0.5px 0;
    }
    
    .calendar-table th {
        padding: 6px 2px;
        font-size: 0.75em;
    }
}

/* Today Highlight */
.calendar-day.today {
    background: #fff3cd;
    border-color: #ffc107;
}

.calendar-day.today.has-events {
    background: #fff8e1;
}

.calendar-day.today .day-number {
    color: #856404;
    font-weight: bold;
}

/* Print Styles */
@media print {
    .wp-outlook-calendar shadow{
        border: 1px solid #000;
    }
    
    .calendar-nav {
        display: none;
    }
    
    .calendar-day {
        height: auto;
        min-height: 60px;
    }
    
    .day-events {
        max-height: none;
        overflow: visible;
    }
    
    .event {
        background: #000 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* Accessibility */
.calendar-nav:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.calendar-day:focus {
    outline: 2px solid #007cba;
    outline-offset: -2px;
}

/* Animation for loading */
.calendar-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wp-outlook-calendar {
        border: 2px solid #000;
    }
    
    .calendar-day {
        border: 1px solid #000;
    }
    
    .event {
        background: #000;
        color: #fff;
        border: 1px solid #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .day-events,
    .calendar-nav,
    .event {
        transition: none;
    }
    
    .calendar-loading::after {
        animation: none;
    }
}
