/**
 * US Law Forms Styling
 * Styles for Gravity Forms integration and subscription forms
 */

/* State Checkboxes Grid Layout - Default 4 columns */
.uslaw-state-checkboxes-grid .gchoice {
    display: inline-block !important;
    width: 23% !important; /* 4 columns on desktop */
    margin-right: 2% !important;
    margin-bottom: 10px !important;
    vertical-align: top;
}

.uslaw-state-checkboxes-grid .gchoice:nth-child(4n) {
    margin-right: 0 !important; /* Remove margin from last item in each row */
}

/* 3 Column Layout */
.uslaw-grid-3-cols .gchoice {
    width: 31% !important;
    margin-right: 3.5% !important;
}

.uslaw-grid-3-cols .gchoice:nth-child(4n) {
    margin-right: 3.5% !important; /* Reset 4-column margin */
}

.uslaw-grid-3-cols .gchoice:nth-child(3n) {
    margin-right: 0 !important;
}

/* 5 Column Layout */
.uslaw-grid-5-cols .gchoice {
    width: 18.4% !important;
    margin-right: 2% !important;
}

.uslaw-grid-5-cols .gchoice:nth-child(4n) {
    margin-right: 2% !important; /* Reset 4-column margin */
}

.uslaw-grid-5-cols .gchoice:nth-child(5n) {
    margin-right: 0 !important;
}

/* 6 Column Layout */
.uslaw-grid-6-cols .gchoice {
    width: 15% !important;
    margin-right: 2% !important;
}

.uslaw-grid-6-cols .gchoice:nth-child(4n) {
    margin-right: 2% !important; /* Reset 4-column margin */
}

.uslaw-grid-6-cols .gchoice:nth-child(6n) {
    margin-right: 0 !important;
}

/* Ensure checkboxes align properly */
.uslaw-state-checkboxes-grid .gchoice {
    display: inline-block !important;
    vertical-align: top !important;
}

.uslaw-state-checkboxes-grid .gchoice label {
    display: inline-block !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
}

.uslaw-state-checkboxes-grid .gchoice input[type="checkbox"] {
    display: inline-block !important;
    margin: 0 6px 0 0 !important;
    vertical-align: middle !important;
    position: relative !important;
    top: -1px !important;
    float: none !important;
    width: auto !important;
    height: auto !important;
}

/* Override any Gravity Forms specific styling that might interfere */
.uslaw-state-checkboxes-grid .gfield_checkbox li,
.uslaw-state-checkboxes-grid .gchoice {
    display: inline-block !important;
    width: auto !important;
    float: none !important;
    vertical-align: top !important;
    margin-bottom: 10px !important;
}

.uslaw-state-checkboxes-grid .gfield_checkbox li label,
.uslaw-state-checkboxes-grid .gchoice label {
    display: inline !important;
    float: none !important;
    width: auto !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
    vertical-align: middle !important;
    line-height: normal !important;
}

.uslaw-state-checkboxes-grid .gfield_checkbox li input[type="checkbox"],
.uslaw-state-checkboxes-grid .gchoice input[type="checkbox"] {
    display: inline !important;
    float: none !important;
    margin: 0 6px 0 0 !important;
    vertical-align: middle !important;
    position: static !important;
    clear: none !important;
}

/* Force inline layout - most important rules */
.uslaw-state-checkboxes-grid * {
    box-sizing: border-box !important;
}

.uslaw-state-checkboxes-grid label::before,
.uslaw-state-checkboxes-grid label::after {
    display: none !important;
}

/* Container styling */
.uslaw-state-checkboxes-grid {
    max-width: 100%;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin: 10px 0;
}

/* Add a select all option styling if needed */
.uslaw-state-checkboxes-grid .select-all-states {
    width: 100% !important;
    margin-bottom: 15px !important;
    padding-bottom: 15px !important;
    border-bottom: 2px solid #ddd;
    font-weight: bold;
}

/* Tablet view - 3 columns */
@media screen and (max-width: 1024px) and (min-width: 641px) {
    .uslaw-state-checkboxes-grid .gchoice {
        width: 31% !important; /* 3 columns */
        margin-right: 3.5% !important;
    }
    
    .uslaw-state-checkboxes-grid .gchoice:nth-child(4n) {
        margin-right: 3.5% !important; /* Reset 4-column margin */
    }
    
    .uslaw-state-checkboxes-grid .gchoice:nth-child(3n) {
        margin-right: 0 !important; /* Remove margin from last item in each row */
    }
}

/* Mobile view - 2 columns */
@media screen and (max-width: 640px) {
    .uslaw-state-checkboxes-grid .gchoice {
        width: 48% !important; /* 2 columns */
        margin-right: 4% !important;
    }
    
    .uslaw-state-checkboxes-grid .gchoice:nth-child(4n),
    .uslaw-state-checkboxes-grid .gchoice:nth-child(3n) {
        margin-right: 4% !important; /* Reset previous margins */
    }
    
    .uslaw-state-checkboxes-grid .gchoice:nth-child(2n) {
        margin-right: 0 !important; /* Remove margin from last item in each row */
    }
    
    .uslaw-state-checkboxes-grid .gchoice label {
        font-size: 13px; /* Slightly smaller text on mobile */
    }
}

/* Very small mobile - single column */
@media screen and (max-width: 380px) {
    .uslaw-state-checkboxes-grid .gchoice {
        width: 100% !important; /* Single column */
        margin-right: 0 !important;
    }
}

/* Hover effect for better UX */
.uslaw-state-checkboxes-grid .gchoice:hover {
    background-color: #f0f0f0 !important;
    border-radius: 3px !important;
    padding: 3px 6px !important;
    margin: -3px -6px 7px -6px !important;
}

.uslaw-state-checkboxes-grid .gchoice:hover label {
    color: #333 !important;
}

/* Admin area specific adjustments */
.admin-area .uslaw-state-checkboxes-grid .gchoice {
    width: 31% !important; /* 3 columns in admin by default */
    margin-right: 3.5% !important;
}

.admin-area .uslaw-state-checkboxes-grid .gchoice:nth-child(3n) {
    margin-right: 0 !important;
}

/* Optional: Add a nice scrollable container if there are many options */
.uslaw-state-checkboxes-grid.scrollable {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Custom scrollbar for webkit browsers */
.uslaw-state-checkboxes-grid.scrollable::-webkit-scrollbar {
    width: 8px;
}

.uslaw-state-checkboxes-grid.scrollable::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.uslaw-state-checkboxes-grid.scrollable::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.uslaw-state-checkboxes-grid.scrollable::-webkit-scrollbar-thumb:hover {
    background: #555;
}