/* Gravity Forms Dataverse Integration - Frontend Styles */

/* Data Tables */
.gfdv-data-table,
.gfdv-submissions-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

.gfdv-data-table th,
.gfdv-data-table td,
.gfdv-submissions-table th,
.gfdv-submissions-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.gfdv-data-table th,
.gfdv-submissions-table th {
    background-color: #f5f5f5;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background-color 0.3s ease;
}

.gfdv-data-table th:hover,
.gfdv-submissions-table th:hover {
    background-color: #eeeeee;
}

.gfdv-data-table th.asc::after,
.gfdv-submissions-table th.asc::after {
    content: " ▲";
    font-size: 0.8em;
    color: #007cba;
}

.gfdv-data-table th.desc::after,
.gfdv-submissions-table th.desc::after {
    content: " ▼";
    font-size: 0.8em;
    color: #007cba;
}

.gfdv-data-table tbody tr,
.gfdv-submissions-table tbody tr {
    transition: background-color 0.2s ease;
}

.gfdv-data-table tbody tr:hover,
.gfdv-submissions-table tbody tr:hover {
    background-color: #f9f9f9;
}

.gfdv-data-table tbody tr:nth-child(even),
.gfdv-submissions-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

/* Data List */
.gfdv-data-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.gfdv-data-item {
    padding: 20px;
    margin-bottom: 15px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gfdv-data-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.gfdv-data-item strong {
    color: #333;
    font-weight: 600;
}

/* Data Grid */
.gfdv-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.gfdv-grid-item {
    padding: 20px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gfdv-grid-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.gfdv-grid-item .gfdv-field {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.gfdv-grid-item .gfdv-field:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.gfdv-grid-item .gfdv-label {
    font-weight: 600;
    color: #555;
    display: inline-block;
    margin-right: 8px;
}

.gfdv-grid-item .gfdv-value {
    color: #333;
}

/* Modal */
.gfdv-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gfdv-modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    border: none;
    width: 90%;
    max-width: 700px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.gfdv-modal-close {
    color: #aaa;
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
}

.gfdv-modal-close:hover,
.gfdv-modal-close:focus {
    color: #000;
}

.gfdv-modal-body h2 {
    margin-top: 0;
    color: #333;
    font-size: 24px;
}

/* Entry Details */
.gfdv-entry-details {
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
}

.gfdv-entry-details th {
    background-color: #f8f9fa;
    padding: 12px;
    text-align: left;
    width: 35%;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e0e0e0;
}

.gfdv-entry-details td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
    color: #333;
}

.gfdv-entry-date {
    color: #6c757d;
    font-style: italic;
    margin: 10px 0;
}

.gfdv-dataverse-id {
    background-color: #e3f2fd;
    color: #1976d2;
    padding: 6px 12px;
    border-radius: 4px;
    display: inline-block;
    font-family: monospace;
    font-size: 14px;
    margin: 10px 0;
}

/* Buttons */
.gfdv-refresh-data,
.gfdv-export-data,
.gfdv-load-more {
    background-color: #007cba;
    color: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: inline-block;
    margin: 5px;
}

.gfdv-refresh-data:hover,
.gfdv-export-data:hover,
.gfdv-load-more:hover {
    background-color: #005a87;
    transform: translateY(-1px);
}

.gfdv-refresh-data:active,
.gfdv-export-data:active,
.gfdv-load-more:active {
    transform: translateY(0);
}

.gfdv-refresh-data:disabled,
.gfdv-export-data:disabled,
.gfdv-load-more:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* View Entry Links */
.gfdv-view-entry {
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.gfdv-view-entry:hover {
    color: #005a87;
    text-decoration: underline;
}

/* Filter Form */
.gfdv-filter-form {
    background-color: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
    border: 1px solid #e0e0e0;
}

.gfdv-filter-form h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

.gfdv-filter-form .form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.gfdv-filter-form .form-group {
    flex: 1;
    min-width: 200px;
}

.gfdv-filter-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

.gfdv-filter-form input,
.gfdv-filter-form select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gfdv-filter-form input:focus,
.gfdv-filter-form select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.25);
}

.gfdv-filter-form button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 25px;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 500;
    margin-right: 10px;
    transition: background-color 0.2s ease;
}

.gfdv-filter-form button:hover {
    background-color: #218838;
}

.gfdv-filter-form button[type="reset"] {
    background-color: #6c757d;
}

.gfdv-filter-form button[type="reset"]:hover {
    background-color: #5a6268;
}

/* Messages */
.gfdv-login-required,
.gfdv-no-results,
.gfdv-no-data {
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: center;
}

.gfdv-login-required {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.gfdv-no-results,
.gfdv-no-data {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.gfdv-success-message {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
}

/* Loading States */
.gfdv-loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.gfdv-loading::before {
    content: "";
    display: inline-block;
    width: 24px;
    height: 24px;
    margin-right: 10px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: gfdv-spin 1s linear infinite;
    vertical-align: middle;
}

@keyframes gfdv-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Container Styles */
.gfdv-data-container {
    margin: 20px 0;
}

.gfdv-submissions-container {
    overflow-x: auto;
    margin: 20px 0;
}

/* Action Buttons Container */
.gfdv-actions {
    margin: 20px 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Pagination */
.gfdv-pagination {
    margin: 30px 0;
    text-align: center;
}

.gfdv-pagination a,
.gfdv-pagination span {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 3px;
    background-color: #f8f9fa;
    color: #333;
    text-decoration: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.gfdv-pagination a:hover {
    background-color: #e9ecef;
}

.gfdv-pagination .current {
    background-color: #007cba;
    color: white;
    border-color: #007cba;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gfdv-data-grid {
        grid-template-columns: 1fr;
    }
    
    .gfdv-modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
    
    .gfdv-data-table,
    .gfdv-submissions-table {
        font-size: 14px;
    }
    
    .gfdv-data-table th,
    .gfdv-data-table td,
    .gfdv-submissions-table th,
    .gfdv-submissions-table td {
        padding: 8px;
    }
    
    .gfdv-filter-form .form-row {
        flex-direction: column;
    }
    
    .gfdv-filter-form .form-group {
        width: 100%;
    }
    
    /* Make tables horizontally scrollable on mobile */
    .gfdv-submissions-container {
        -webkit-overflow-scrolling: touch;
    }
    
    .gfdv-submissions-table,
    .gfdv-data-table {
        min-width: 600px;
    }
}

@media (max-width: 480px) {
    .gfdv-modal-content {
        margin: 20% auto;
    }
    
    .gfdv-actions {
        flex-direction: column;
    }
    
    .gfdv-actions button {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    .gfdv-refresh-data,
    .gfdv-export-data,
    .gfdv-load-more,
    .gfdv-filter-form,
    .gfdv-actions {
        display: none !important;
    }
    
    .gfdv-data-table,
    .gfdv-submissions-table {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .gfdv-modal {
        display: none !important;
    }
}