/**
 * Syngenta Safras Styles
 * Table layout with horizontal scroll on mobile
 */

.ss-safras-container {
    width: 100%;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Legend */
.ss-safras-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.ss-safras-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ss-safras-legend-color {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 1px solid #ddd;
    border-radius: 2px;
    flex-shrink: 0;
}

.ss-safras-legend-text {
    font-size: 14px;
    color: #333;
}

/* Table Wrapper - Horizontal Scroll */
.ss-safras-table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.ss-safras-table {
    display: flex;
    flex-direction: column;
    min-width: 100%;
}

/* Row */
.ss-safras-row {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
}

.ss-safras-row:last-child {
    border-bottom: none;
}

/* Header Row */
.ss-safras-header-row {
    background-color: #f5f5f5;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Cell Base */
.ss-safras-cell {
    padding: 12px 8px;
    font-size: 14px;
    line-height: 1.4;
    border-right: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 44px;
    box-sizing: border-box;
}

.ss-safras-cell:last-child {
    border-right: none;
}

/* Fixed Columns (Left Side) */
.ss-safras-cell-fixed {
    position: sticky;
    left: 0;
    background-color: #fff;
    z-index: 5;
    min-width: 120px;
    font-weight: 500;
}

.ss-safras-header-row .ss-safras-cell-fixed {
    background-color: #f5f5f5;
    z-index: 15;
}

.ss-safras-data-row:nth-child(even) .ss-safras-cell-fixed {
    background-color: #fafafa;
}

/* Month Group */
.ss-safras-month-group {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
    min-width: 150px;
}

.ss-safras-month-header {
    padding: 10px 8px;
    font-weight: 600;
    font-size: 14px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
}

/* Periods Row (Header) */
.ss-safras-periods-row {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
}

.ss-safras-period-cell {
    flex: 1;
    padding: 8px 4px;
    font-size: 12px;
    font-weight: 500;
    min-height: 36px;
}

/* Data Cell */
.ss-safras-data-cell {
    flex: 1;
    padding: 10px 4px;
    font-size: 13px;
    min-height: 50px;
    border-right: 1px solid #e0e0e0;
}

.ss-safras-data-cell:last-child {
    border-right: none;
}

/* Cell Colors */
.ss-safras-cell-preferencial {
    background-color: #2d5016;
    color: #ffffff;
    font-weight: 500;
}

.ss-safras-cell-nao-preferencial {
    background-color: #7cb342;
    color: #ffffff;
    font-weight: 500;
}

.ss-safras-cell-empty {
    background-color: #ffffff;
    color: #666;
}

/* Responsive - Mobile */
@media screen and (max-width: 768px) {
    .ss-safras-container {
        margin: 15px 0;
    }

    .ss-safras-legend {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
        font-size: 13px;
    }

    .ss-safras-table-wrapper {
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    .ss-safras-cell-fixed {
        min-width: 100px;
        font-size: 12px;
        padding: 10px 6px;
    }

    .ss-safras-month-group {
        min-width: 140px;
    }

    .ss-safras-month-header {
        font-size: 13px;
        padding: 8px 6px;
    }

    .ss-safras-period-cell {
        font-size: 11px;
        padding: 6px 3px;
    }

    .ss-safras-data-cell {
        font-size: 12px;
        padding: 8px 3px;
        min-height: 45px;
    }

    /* Improve touch scrolling */
    .ss-safras-table-wrapper {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Scroll indicators */
    .ss-safras-scroll-indicator {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        font-size: 24px;
        color: #999;
        pointer-events: auto;
        opacity: 0.7;
        z-index: 20;
        background-color: rgba(255, 255, 255, 0.9);
        padding: 8px 12px;
        border-radius: 4px;
        cursor: pointer;
        transition: opacity 0.3s;
    }

    .ss-safras-scroll-indicator:hover {
        opacity: 1;
    }

    .ss-safras-scroll-left {
        left: 10px;
    }

    .ss-safras-scroll-right {
        right: 10px;
    }
}

/* Very small screens */
@media screen and (max-width: 480px) {
    .ss-safras-cell-fixed {
        min-width: 90px;
        font-size: 11px;
        padding: 8px 4px;
    }

    .ss-safras-month-group {
        min-width: 130px;
    }

    .ss-safras-data-cell {
        font-size: 11px;
        min-height: 40px;
    }
}

/* Print styles */
@media print {
    .ss-safras-table-wrapper {
        overflow: visible;
    }

    .ss-safras-cell-fixed {
        position: relative;
    }
}

