/**
 * Public styles for Custom Field Manager
 * Enhanced responsive design with modern styling
 */

/* Base container styles */
.cfm-shortcode-container {
    max-width: 100%;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.6;
}

.cfm-records-container {
    max-width: 100%;
    margin: 0;
}

/* Search container styles */
.cfm-search-container {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.cfm-search-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cfm-search-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.cfm-search-input::placeholder {
    color: #757575;
}

.cfm-search-clear {
    padding: 12px 20px;
    background-color: #f8f9fa;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.cfm-search-clear:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.cfm-search-clear:active {
    transform: translateY(1px);
}

/* Loading state */
.cfm-searching .cfm-records-wrapper {
    position: relative;
}

.cfm-searching .cfm-records-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Table wrapper for horizontal scrolling */
.cfm-records-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    background: #fff;
    transition: opacity 0.2s ease;
}

/* Table styles */
.cfm-records-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    min-width: 600px;
    font-size: 14px;
}

.cfm-records-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.cfm-records-table th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    position: relative;
}

.cfm-records-table th:first-child {
    border-top-left-radius: 12px;
}

.cfm-records-table th:last-child {
    border-top-right-radius: 12px;
}

.cfm-records-table td {
    padding: 14px 12px;
    border-bottom: 1px solid #f1f3f4;
    color: #495057;
    vertical-align: top;
}

.cfm-records-table tbody tr {
    transition: background-color 0.2s ease;
}

.cfm-records-table tbody tr:hover {
    background-color: #f8f9fa;
}

.cfm-records-table tbody tr:last-child td {
    border-bottom: none;
}

.cfm-records-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 12px;
}

.cfm-records-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

/* Field type specific styles */
.cfm-field-text,
.cfm-field-textarea,
.cfm-field-select,
.cfm-field-radio {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cfm-field-textarea {
    white-space: normal;
    line-height: 1.5;
    max-height: 80px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.cfm-field-number {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.cfm-field-date {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.cfm-field-checkbox {
    font-size: 12px;
    line-height: 1.4;
}

.cfm-field-checkbox .cfm-checkbox-item {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 3px 8px;
    margin: 1px 2px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* Value formatting */
.cfm-text-value,
.cfm-option-value {
    display: inline-block;
}

.cfm-number-value {
    font-weight: 500;
    color: #2563eb;
}

.cfm-date-value {
    color: #059669;
    font-weight: 500;
}

.cfm-empty-value {
    color: #9ca3af;
    font-style: italic;
}

.cfm-textarea-content {
    line-height: 1.5;
}

/* No results states */
.cfm-no-results,
.cfm-no-records td {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-style: italic;
    background: #f9fafb;
}

.cfm-no-fields,
.cfm-no-display-fields,
.cfm-error {
    text-align: center;
    padding: 30px 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    margin: 20px 0;
}

.cfm-records-placeholder {
    padding: 30px 20px;
    background: #f0f9ff;
    border: 2px dashed #0ea5e9;
    border-radius: 8px;
    text-align: center;
    color: #0369a1;
    font-weight: 500;
}

/* Accessibility */
.screen-reader-text {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    width: 1px !important;
    height: 1px !important;
    overflow: hidden;
}

.cfm-search-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .cfm-records-table {
        min-width: 500px;
    }
    
    .cfm-field-text,
    .cfm-field-textarea,
    .cfm-field-select,
    .cfm-field-radio {
        max-width: 180px;
    }
}

@media (max-width: 768px) {
    .cfm-shortcode-container {
        margin: 15px 0;
    }
    
    .cfm-search-container {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .cfm-search-input {
        min-width: auto;
        width: 100%;
    }
    
    .cfm-search-clear {
        align-self: flex-start;
        width: auto;
    }
    
    .cfm-records-wrapper {
        border-radius: 8px;
        margin: 0 -10px;
    }
    
    .cfm-records-table {
        min-width: 450px;
    }
    
    .cfm-records-table th,
    .cfm-records-table td {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .cfm-records-table th {
        font-size: 11px;
    }
    
    .cfm-field-text,
    .cfm-field-textarea,
    .cfm-field-select,
    .cfm-field-radio {
        max-width: 140px;
    }
    
    .cfm-field-textarea {
        max-height: 60px;
        -webkit-line-clamp: 2;
    }
}

@media (max-width: 480px) {
    .cfm-shortcode-container {
        margin: 10px 0;
    }
    
    .cfm-records-wrapper {
        margin: 0 -15px;
        border-radius: 6px;
    }
    
    .cfm-records-table {
        min-width: 380px;
    }
    
    .cfm-records-table th,
    .cfm-records-table td {
        padding: 8px 6px;
        font-size: 12px;
    }
    
    .cfm-records-table th {
        font-size: 10px;
        padding: 12px 6px;
    }
    
    .cfm-field-text,
    .cfm-field-textarea,
    .cfm-field-select,
    .cfm-field-radio {
        max-width: 100px;
    }
    
    .cfm-field-checkbox .cfm-checkbox-item {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .cfm-no-results,
    .cfm-no-records td {
        padding: 30px 15px;
        font-size: 13px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .cfm-records-table {
        background-color: #1f2937;
        color: #f9fafb;
    }
    
    .cfm-records-table td {
        border-bottom-color: #374151;
        color: #e5e7eb;
    }
    
    .cfm-records-table tbody tr:hover {
        background-color: #374151;
    }
    
    .cfm-search-input {
        background-color: #1f2937;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .cfm-search-input:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    
    .cfm-search-clear {
        background-color: #374151;
        border-color: #4b5563;
        color: #e5e7eb;
    }
    
    .cfm-search-clear:hover {
        background-color: #4b5563;
        border-color: #6b7280;
    }
    
    .cfm-records-wrapper {
        background: #1f2937;
    }
}

/* Print styles */
@media print {
    .cfm-search-container {
        display: none;
    }
    
    .cfm-records-wrapper {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .cfm-records-table th {
        background: #f0f0f0 !important;
        color: #000 !important;
    }
    
    .cfm-records-table tbody tr:hover {
        background: transparent !important;
    }
}
/* Addi
tional utility classes */
.cfm-search-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 14px;
    display: none;
}

.cfm-loading {
    opacity: 0.6;
    pointer-events: none;
}

.cfm-fade-in {
    animation: cfmFadeIn 0.3s ease-in;
}

@keyframes cfmFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.cfm-highlight {
    background-color: #fef3c7;
    padding: 1px 3px;
    border-radius: 3px;
}

/* Focus management */
.cfm-records-table:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cfm-records-table th {
        background: #000 !important;
        color: #fff !important;
        border: 1px solid #fff;
    }
    
    .cfm-records-table td {
        border: 1px solid #000;
    }
    
    .cfm-search-input {
        border: 2px solid #000;
    }
    
    .cfm-search-clear {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
}