/**
 * DataDive Feature Styles
 * 
 * Styles specific to the DataDive data export interface.
 */

/* ========================================
   DataDive Form Styles
   ======================================== */

.datadive-form {
    max-width: 100%;
}

.form-group {
    margin-bottom: 20px;
}

.form-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: nowrap;
}

.form-group-label {
    flex: 1;
    min-width: 0;
}

.form-group-header > button {
    flex-shrink: 0;
    white-space: nowrap;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #107c10;
}

.form-group label .help-text {
    font-weight: normal;
    color: #b0b0b0;
    font-size: 0.9em;
    margin-left: 8px;
}

.form-control {
    width: 100%;
    padding: 12px;
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid rgba(16, 124, 16, 0.3);
    border-radius: 6px;
    color: #ffffff;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.form-control:focus {
    outline: none;
    border-color: #107c10;
    box-shadow: 0 0 0 3px rgba(16, 124, 16, 0.1);
}

/* Select dropdown with custom chevron matching icon size */
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z' fill='%23ffffff'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Date input styling for dark mode */
input[type="date"].form-control,
textarea.form-control {
    color-scheme: dark;
}

.form-hint {
    display: block;
    margin-top: 6px;
    color: #888;
    font-size: 0.85em;
}

.checkbox-group {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid rgba(16, 124, 16, 0.3);
    border-radius: 6px;
    padding: 12px;
    background: rgba(30, 30, 30, 0.5);
}

.form-check {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.form-check:hover {
    background: rgba(16, 124, 16, 0.1);
}

.form-check-input {
    width: 16px;
    height: 16px;
    margin-right: 0;
    cursor: pointer;
    accent-color: #107c10;
    flex-shrink: 0;
}

.form-check-label {
    cursor: pointer;
    color: #e0e0e0;
    user-select: none;
    font-size: 14px;
    flex: 1;
}

.btn-link-inline {
    background: none;
    border: none;
    color: #107c10;
    padding: 0 8px;
    cursor: pointer;
    font-size: 0.9em;
    text-decoration: underline;
}

.btn-link-inline:hover {
    color: #0d6b0d;
}

/* ========================================
   Custom Multi-Select Dropdown
   ======================================== */

.custom-multiselect {
    position: relative;
    width: 100%;
}

.multiselect-button {
    width: 100%;
    padding: 12px;
    padding-right: 40px;
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid rgba(16, 124, 16, 0.3);
    border-radius: 6px;
    color: #ffffff;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', monospace;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.multiselect-button:hover {
    border-color: #107c10;
    background: rgba(40, 40, 40, 0.9);
}

.multiselect-button:focus {
    outline: none;
    border-color: #107c10;
    box-shadow: 0 0 0 3px rgba(16, 124, 16, 0.1);
}

.multiselect-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
}

.multiselect-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.multiselect-button[aria-expanded="true"] .multiselect-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: rgba(30, 30, 30, 0.98);
    border: 1px solid rgba(16, 124, 16, 0.3);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    max-height: 400px;
    display: flex;
    flex-direction: column;
}

.multiselect-search {
    padding: 12px;
    border-bottom: 1px solid rgba(16, 124, 16, 0.2);
}

.multiselect-search-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid rgba(16, 124, 16, 0.3);
    border-radius: 4px;
    color: #ffffff;
    font-size: 13px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.multiselect-search-input:focus {
    outline: none;
    border-color: #107c10;
}

.multiselect-search-input::placeholder {
    color: #888;
}

.multiselect-actions {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(16, 124, 16, 0.2);
    display: flex;
    gap: 8px;
}

.multiselect-action-btn {
    flex: 1;
    padding: 6px 12px;
    background: rgba(16, 124, 16, 0.2);
    border: 1px solid rgba(16, 124, 16, 0.3);
    border-radius: 4px;
    color: #107c10;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.multiselect-action-btn:hover {
    background: rgba(16, 124, 16, 0.3);
}

.multiselect-options {
    overflow-y: auto;
    max-height: 280px;
    padding: 8px;
}

.multiselect-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s ease;
    gap: 12px;
    user-select: none;
}

.multiselect-option:hover {
    background: rgba(16, 124, 16, 0.2);
}

.multiselect-checkbox {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: #107c10;
    flex-shrink: 0;
}

.multiselect-option span {
    color: #e0e0e0;
    font-size: 14px;
    flex: 1;
}

.multiselect-empty {
    padding: 20px;
    text-align: center;
    color: #888;
    font-style: italic;
}

.date-range-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.date-field {
    display: flex;
    flex-direction: column;
}

.date-input {
    padding: 10px 12px;
}

@media (max-width: 768px) {
    .date-range-container {
        grid-template-columns: 1fr;
    }
}

.form-field-label {
    font-size: 0.8em;
    color: #b0b0b0;
    margin-bottom: 6px;
    font-weight: normal;
}

/* ========================================
   Custom Sampling Section
   ======================================== */

.custom-sampling-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sampling-field {
    display: flex;
    flex-direction: column;
}

.sampling-input {
    padding: 10px 12px;
}

/* ========================================
   Action Buttons
   ======================================== */

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #107c10;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #0d6b0d;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(16, 124, 16, 0.3);
}

.btn-secondary {
    background: rgba(60, 60, 60, 0.9);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(80, 80, 80, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(60, 60, 60, 0.3);
}

.btn-collapse {
    padding: 8px 16px !important;
    font-size: 13px;
    height: fit-content;
    min-height: auto;
}

.btn-info {
    background: #0078d4;
    color: white;
}

.btn-info:hover:not(:disabled) {
    background: #006cbe;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 120, 212, 0.3);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    background: rgba(16, 124, 16, 0.2);
    border: 1px solid rgba(16, 124, 16, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    color: #107c10;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-icon:hover {
    background: rgba(16, 124, 16, 0.3);
    transform: translateY(-1px);
}

.btn-icon i {
    font-size: 12px;
}

/* ========================================
   Alert Messages
   ======================================== */

.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-success {
    background: rgba(16, 124, 16, 0.2);
    border: 1px solid rgba(16, 124, 16, 0.5);
    color: #4ade80;
}

.alert-error {
    background: rgba(220, 53, 69, 0.2);
    border: 1px solid rgba(220, 53, 69, 0.5);
    color: #f87171;
}

.alert-info {
    background: rgba(0, 120, 212, 0.2);
    border: 1px solid rgba(0, 120, 212, 0.5);
    color: #60a5fa;
}

.alert-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

/* ========================================
   Results Display
   ======================================== */

.result-card {
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid rgba(16, 124, 16, 0.3);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(16, 124, 16, 0.2);
}

.result-title {
    font-size: 18px;
    font-weight: 600;
    color: #107c10;
}

.result-meta {
    color: #888;
    font-size: 14px;
}

.result-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ========================================
   Count Display
   ======================================== */

.count-display {
    text-align: center;
    padding: 40px 20px;
}

.count-number {
    font-size: 48px;
    font-weight: 700;
    color: #107c10;
    margin-bottom: 8px;
}

.count-label {
    font-size: 16px;
    color: #b0b0b0;
}

/* ========================================
   Sample Data Table
   ======================================== */

.sample-table-wrapper {
    max-height: 600px;
    overflow: auto;
    border: 1px solid rgba(16, 124, 16, 0.2);
    border-radius: 6px;
    margin-top: 16px;
    position: relative;
    background: rgba(20, 20, 20, 0.5);
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.sample-table-wrapper.collapsed {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    margin-top: 0;
    border: none;
}

.sample-table-container {
    min-width: 100%;
}

.sample-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sample-table th {
    background: rgba(16, 124, 16, 0.25);
    color: #107c10;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border-bottom: 2px solid rgba(16, 124, 16, 0.5);
}

.sample-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
}

.sample-table tr:hover {
    background: rgba(16, 124, 16, 0.1);
}

/* Scroll indicator gradient at bottom */
.sample-table-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, rgba(20, 20, 20, 0.95), transparent);
    pointer-events: none;
}

/* ========================================
   Export Status
   ======================================== */

.export-status {
    padding: 20px;
    text-align: center;
}

.export-status .status-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.export-status.running .status-icon {
    color: #0078d4;
    animation: spin 2s linear infinite;
}

.export-status.completed .status-icon {
    color: #107c10;
}

.export-status.error .status-icon {
    color: #dc3545;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.download-links {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.download-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #107c10;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.download-link:hover {
    background: #0d6b0d;
    transform: translateY(-1px);
}

/* ========================================
   History Table
   ======================================== */

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.history-table th {
    background: rgba(16, 124, 16, 0.2);
    color: #107c10;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.history-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

.history-table tr:hover {
    background: rgba(16, 124, 16, 0.1);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-completed {
    background: rgba(16, 124, 16, 0.3);
    color: #4ade80;
}

.status-running {
    background: rgba(0, 120, 212, 0.3);
    color: #60a5fa;
}

.status-error {
    background: rgba(220, 53, 69, 0.3);
    color: #f87171;
}

.status-initiated {
    background: rgba(255, 193, 7, 0.3);
    color: #fbbf24;
}

/* ========================================
   Utility Styles
   ======================================== */

.loading-message {
    text-align: center;
    color: #888;
    padding: 40px 20px;
}

.empty-message {
    text-align: center;
    color: #888;
    padding: 40px 20px;
}

/* ========================================
   High-Volume Export Warning Modal
   ======================================== */

.export-warning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.export-warning-modal {
    background: rgba(20, 20, 20, 0.95);
    border: 2px solid #ff9800;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(255, 152, 0, 0.3);
}

.warning-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 152, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 16px;
}

.warning-header i {
    font-size: 32px;
    color: #ff9800;
}

.warning-header h3 {
    margin: 0;
    color: #ff9800;
    font-size: 24px;
}

.warning-content {
    padding: 24px;
    color: #e0e0e0;
}

.warning-details {
    margin-top: 20px;
    padding: 16px;
    background: rgba(255, 152, 0, 0.1);
    border-left: 3px solid #ff9800;
    border-radius: 4px;
}

.warning-details strong {
    color: #ff9800;
    font-size: 16px;
}

.warning-details ul {
    margin: 12px 0 0 0;
    padding-left: 20px;
}

.warning-details li {
    margin: 8px 0;
}

.warning-details span {
    color: #fff;
    font-weight: 600;
}

.warning-actions {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 152, 0, 0.3);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.timeout-suggestions {
    margin-top: 20px;
    padding: 16px;
    background: rgba(220, 53, 69, 0.1);
    border-left: 3px solid #dc3545;
    border-radius: 4px;
}

.timeout-suggestions ul {
    margin: 12px 0 0 0;
    padding-left: 20px;
}

.timeout-suggestions li {
    margin: 8px 0;
}

/* ========================================
   Light Mode Overrides
   ======================================== */

body.light-mode .form-group label {
    color: #107c10;
}

body.light-mode .form-group label .help-text {
    color: #6c757d;
}

body.light-mode .form-control {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(16, 124, 16, 0.3);
    color: #212529;
}

body.light-mode .form-control:focus {
    border-color: #107c10;
    box-shadow: 0 0 0 3px rgba(16, 124, 16, 0.1);
}

body.light-mode select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z' fill='%23212529'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

body.light-mode input[type="date"].form-control,
body.light-mode textarea.form-control {
    color-scheme: light;
}

body.light-mode .form-hint {
    color: #6c757d;
}

body.light-mode .checkbox-group {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(16, 124, 16, 0.3);
}

body.light-mode .form-check:hover {
    background: rgba(16, 124, 16, 0.05);
}

body.light-mode .form-check-label {
    color: #212529;
}

body.light-mode .form-field-label {
    color: #6c757d;
}

body.light-mode .multiselect-button {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(16, 124, 16, 0.3);
    color: #212529;
}

body.light-mode .multiselect-button:hover {
    background: rgba(248, 249, 250, 0.9);
}

body.light-mode .multiselect-arrow {
    /* Arrow color already handled by SVG fill in icons.html */
}

body.light-mode .multiselect-dropdown {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(16, 124, 16, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.light-mode .multiselect-search-input {
    background: rgba(248, 249, 250, 0.9);
    border: 1px solid rgba(16, 124, 16, 0.3);
    color: #212529;
}

body.light-mode .multiselect-search-input::placeholder {
    color: #6c757d;
}

body.light-mode .multiselect-action-btn {
    background: rgba(16, 124, 16, 0.1);
    border: 1px solid rgba(16, 124, 16, 0.3);
    color: #107c10;
}

body.light-mode .multiselect-action-btn:hover {
    background: rgba(16, 124, 16, 0.2);
}

body.light-mode .multiselect-option:hover {
    background: rgba(16, 124, 16, 0.1);
}

body.light-mode .multiselect-option span {
    color: #212529;
}

body.light-mode .multiselect-empty {
    color: #6c757d;
}

body.light-mode .btn-secondary {
    background: rgba(248, 249, 250, 0.9);
    color: #212529;
}

body.light-mode .btn-secondary:hover:not(:disabled) {
    background: rgba(233, 236, 239, 0.9);
}

body.light-mode .btn-icon {
    background: rgba(16, 124, 16, 0.1);
    border: 1px solid rgba(16, 124, 16, 0.3);
    color: #107c10;
}

body.light-mode .btn-icon:hover {
    background: rgba(16, 124, 16, 0.2);
}

body.light-mode .result-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(16, 124, 16, 0.3);
}

body.light-mode .result-header {
    border-bottom: 1px solid rgba(16, 124, 16, 0.2);
}

body.light-mode .result-meta {
    color: #6c757d;
}

body.light-mode .count-label {
    color: #6c757d;
}

body.light-mode .sample-table-wrapper {
    background: rgba(248, 249, 250, 0.8);
    border: 1px solid rgba(16, 124, 16, 0.2);
}

body.light-mode .sample-table th {
    background: rgba(16, 124, 16, 0.15);
    border-bottom: 2px solid rgba(16, 124, 16, 0.3);
}

body.light-mode .sample-table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    color: #212529;
}

body.light-mode .sample-table tr:hover {
    background: rgba(16, 124, 16, 0.05);
}

body.light-mode .sample-table-wrapper::after {
    background: linear-gradient(to top, rgba(248, 249, 250, 0.95), transparent);
}

body.light-mode .loading-message,
body.light-mode .empty-message {
    color: #6c757d;
}

body.light-mode .export-warning-modal {
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid #ff9800;
}

body.light-mode .warning-content {
    color: #212529;
}

body.light-mode .warning-header {
    border-bottom: 1px solid rgba(255, 152, 0, 0.3);
}

body.light-mode .warning-actions {
    border-top: 1px solid rgba(255, 152, 0, 0.3);
}

body.light-mode .history-table th {
    background: rgba(16, 124, 16, 0.1);
}

body.light-mode .history-table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    color: #212529;
}

body.light-mode .history-table tr:hover {
    background: rgba(16, 124, 16, 0.05);
}
