/**
 * BananaTrends Core - Frontend Styles
 *
 * @package BananaTrends_Core
 * @since 1.0.0
 */

/* Main Calendar Styles */
.bananatrends-calendar {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    max-width: 100%;
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #f9f9f9;
}

.bananatrends-calendar-header {
    margin-bottom: 20px;
}

.calendar-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.calendar-title h3 {
    color: #2c5530;
    font-size: 1.5em;
    font-weight: 600;
    margin: 0;
}

.month-navigation {
    display: flex;
    align-items: center;
    gap: 10px;
}

.current-month {
    font-size: 1.2em;
    font-weight: 600;
    color: #2c5530;
    min-width: 150px;
    text-align: center;
}

.btn-nav {
    background: #2c5530;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.btn-nav:hover {
    background: #1e3a21;
}

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

/* Calendar Grid Styles */
.calendar-container {
    position: relative;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.calendar-grid-wrapper {
    position: relative;
}

.calendar-grid {
    position: relative;
}

/* SVG Trend Line Overlay */
.bt-svg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.bt-svg .trend-point {
    pointer-events: all;
    cursor: pointer;
}

/* Tooltip Styles */
.bt-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    z-index: 1000;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.bt-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -4px;
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr)) 80px;
    gap: 1px;
    margin-bottom: 10px;
}

.day-header {
    padding: 10px 5px;
    text-align: center;
    font-weight: 600;
    color: #666;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.9em;
}

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr)) auto;
    gap: 1px;
    margin-bottom: 1px;
    position: relative;
}

.calendar-day {
    width: 100%;
    height: 100px;
    min-height: 100px;
    max-height: 100px;
    min-width: 0;
    padding: 0;
    border: 1px solid #e9ecef;
    background: white;
    position: relative;
    transition: all 0.2s ease;
    overflow: hidden;
    box-sizing: border-box;
}

.calendar-day:hover {
    background: #f8f9fa;
    border-color: #2c5530;
}

.calendar-day.has-price {
    background: #e8f5e8;
    border-color: #2c5530;
}

.calendar-day.has-price:hover {
    background: #d4edda;
}

.calendar-day.empty {
    background: #f8f9fa;
    border-color: transparent;
}

.day-number {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    position: absolute;
    top: 5px;
    left: 5px;
    white-space: nowrap;
    pointer-events: none;
}

.day-number.today {
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
    background-color: #2c5530;
    color: white;
    top: 3px;
    left: 3px;
}

.day-price {
    font-size: 15px;
    color: #2c5530;
    font-weight: 700;
    text-align: right;
    line-height: 1.2;
    position: absolute;
    top: 5px;
    right: 5px;
    white-space: nowrap;
    pointer-events: none;
}

.calendar-day.empty .day-number {
    color: #ccc;
}

/* Week Badge */
.week-badge {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px 12px;
    background: #2c5530;
    color: white;
    border-radius: 4px;
    min-width: 80px;
    max-width: 80px;
    width: 80px;
    font-size: 0.8em;
    text-align: center;
}

.week-label {
    font-size: 0.75em;
    opacity: 0.9;
    margin-bottom: 2px;
}

.week-avg {
    font-weight: 600;
    font-size: 1em;
    margin-bottom: 2px;
}

.week-count {
    opacity: 0.8;
    font-size: 0.7em;
}

/* Price Trend Line */
.price-trend-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.price-trend-line path {
    fill: none;
    stroke: #dc3545;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Loading States */
.calendar-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2c5530;
    border-radius: 50%;
    animation: bananatrends-spin 1s linear infinite;
    margin-bottom: 15px;
}

.calendar-error {
    padding: 20px;
    text-align: center;
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 20px 0;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .bananatrends-calendar {
        padding: 15px;
        margin: 10px 0;
    }
    
    .calendar-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .month-navigation {
        align-self: center;
    }
    
    .calendar-day {
        min-height: 60px;
        padding: 6px 3px;
    }
    
    .day-number {
        font-size: 12px;
    }
    
    .day-price {
        font-size: 10px;
    }
    
    .week-badge {
        min-width: 60px;
        padding: 6px 8px;
        font-size: 0.7em;
    }
}

@media (max-width: 480px) {
    .calendar-week {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .week-badge {
        display: none; /* Hide week badges on very small screens */
    }
    
    .calendar-day {
        min-height: 50px;
        padding: 4px 2px;
    }
}
