/* Timeframe Controls Styling */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem auto;
    width: 90%;
    position: relative;
    z-index: 2;
}

.timeframe-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Filter Form */
.filter-condition {
    position: relative;
    margin-bottom: 10px;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.filter-condition:hover {
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}

.filter-condition.main-condition {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    border-left: 3px solid #0d6efd;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.filter-group select,
.filter-group input {
    height: 32px;
    padding: 4px 8px;
    font-size: 0.9rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: #fff;
    transition: all 0.2s ease;
}

.filter-group select:hover,
.filter-group input:hover {
    border-color: #adb5bd;
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 2px rgba(13,110,253,0.15);
    outline: none;
}

.filter-indicator {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
}

.filter-operator {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
}

.filter-value {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
}

.logical-operator select {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    background-color: #f8f9fa;
}

.remove-condition {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #dc3545;
    font-size: 0.9rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.remove-condition:hover {
    opacity: 1;
}

/* Action Buttons */
#addCondition,
#applyFilter {
    padding: 6px 12px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s ease;
}

#addCondition {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
}

#addCondition:hover {
    background-color: #e9ecef;
    border-color: #ced4da;
}

#applyFilter {
    background-color: #0d6efd;
    border: 1px solid #0d6efd;
    color: white;
}

#applyFilter:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

/* Results table layout: see indicator-filter-page.css + screener-page.css */
#resultsTable {
    overflow: visible !important;
    margin-top: 0;
    border: none;
    border-radius: 0;
}

#resultsTable.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Symbol-Dropdown-Styling */
.symbol-dropdown {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ced4da;
    border-radius: 4px;
    margin-top: 4px;
}

.symbol-option {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.symbol-option:hover,
.symbol-option.selected {
    background-color: #e9ecef;
}

/* Responsive Design */
@media (max-width: 768px) {
    .filter-group {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .filter-group select,
    .filter-group input {
        width: calc(50% - 3px);
        max-width: none;
    }
    
    .logical-operator select {
        width: 100%;
        max-width: none;
    }
    
    .timeframe-buttons {
        flex-wrap: wrap;
    }
    
    .timeframe-buttons button {
        flex: 1 1 calc(50% - 4px);
    }
}

.filter-condition.main-condition {
    background-color: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.filter-condition.main-condition .filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-condition.main-condition .filter-indicator {
    /* allow normal look and behavior for first condition dropdown */
    background-color: #fff;
    font-weight: bold;
}

.filter-condition.main-condition .filter-value {
    width: 120px;
    text-align: center;
    font-weight: bold;
} 

/* --- Compact Premium Card Grid Layout --- */

/* Container: Grid layout - side by side on desktop */
#filterConditions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
    width: 100%;
    padding: 8px 0;
    counter-reset: condition-counter;
}

/* Card style for each condition - COMPACT */
.filter-condition {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px 10px;
    margin: 0;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    animation: cardAppear 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    counter-increment: condition-counter;
}

/* Condition number badge - smaller */
.filter-condition::before {
    content: counter(condition-counter);
    position: absolute;
    top: -6px;
    left: 12px;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.4);
    z-index: 3;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.filter-condition:hover {
    box-shadow: 0 3px 12px rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
}

/* New condition highlight effect */
.filter-condition.new-condition {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1), 0 4px 15px rgba(139, 92, 246, 0.15);
}

.filter-condition.new-condition::before {
    animation: pulseBadge 0.5s ease-out;
}

@keyframes pulseBadge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Logic Operator - Colorful Compact Style */
.logical-operator-container {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 2px;
}

.logical-operator-container .form-select {
    display: none;
}

/* Logic Toggle - Professional Clean Style */
.logic-toggle {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 4px !important;
    background: #f1f5f9 !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}

.logic-btn {
    appearance: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 6px 14px !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    min-width: 46px !important;
}

/* AND button - Light Green Background */
.logic-btn.and {
    background: #d1fae5 !important;
    color: #047857 !important;
    border: 1.5px solid #6ee7b7 !important;
}

.logic-btn.and:hover {
    background: #a7f3d0 !important;
    color: #065f46 !important;
    border-color: #34d399 !important;
}

.logic-btn.and.active,
.logic-toggle .logic-btn.and.active,
button.logic-btn.and.active {
    background: #10b981 !important;
    background-image: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
    border: 1.5px solid #059669 !important;
    border-color: #059669 !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.5) !important;
}

/* OR button - Light Red Background */
.logic-btn.or {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border: 1.5px solid #fca5a5 !important;
}

.logic-btn.or:hover {
    background: #fecaca !important;
    color: #991b1b !important;
    border-color: #f87171 !important;
}

.logic-btn.or.active,
.logic-toggle .logic-btn.or.active,
button.logic-btn.or.active {
    background: #ef4444 !important;
    background-image: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: #ffffff !important;
    border: 1.5px solid #dc2626 !important;
    border-color: #dc2626 !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5) !important;
}

/* Filter Inputs Group - COMPACT */
.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.filter-group select,
.filter-group input {
    height: 34px;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background-color: #fafbfc;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #1e293b;
    cursor: pointer;
}

/* Custom dropdown arrow */
.filter-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%236366f1' d='M6 8.5L1.5 4h9L6 8.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 26px;
}

.filter-group select:hover,
.filter-group input:hover {
    border-color: #a5b4fc;
    background-color: #fff;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.1);
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: #6366f1;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    outline: none;
}

/* --- Indicator Select (Purple/Indigo theme) --- */
.filter-indicator { 
    flex: 1.1; 
    min-width: 85px; 
    font-weight: 700 !important;
    color: #6366f1 !important;
    background: linear-gradient(145deg, #eef2ff 0%, #f5f3ff 100%) !important;
    border-color: #c7d2fe !important;
}

.filter-indicator:hover {
    background: linear-gradient(145deg, #e0e7ff 0%, #fff 100%) !important;
    border-color: #818cf8 !important;
}

.filter-indicator:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18) !important;
}

/* --- Operator Select (Slate/Gray theme) --- */
.filter-operator { 
    flex: 1.4; 
    min-width: 100px;
    font-weight: 500;
    color: #475569 !important;
    background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%) !important;
    border-color: #cbd5e1 !important;
}

.filter-operator:hover {
    background: linear-gradient(145deg, #f1f5f9 0%, #fff 100%) !important;
    border-color: #94a3b8 !important;
}

.filter-operator:focus {
    border-color: #64748b !important;
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.12) !important;
}

/* --- Value Input/Select (neutral base; tone via .select-*) --- */
.filter-value { 
    flex: 0.7; 
    min-width: 60px; 
    text-align: center;
    font-weight: 700 !important;
    color: #111827 !important;
    background: #f8fafc !important;
    border-color: #d1d5db !important;
}

.filter-value:hover {
    background: #e5e7eb !important;
    border-color: #9ca3af !important;
}

.filter-value:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.20) !important;
}

/* Value input number styling */
.filter-value::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

/* Signal value select special styling */
select.filter-value {
    text-align: left;
    padding-left: 10px;
}

/* Option styling */
.filter-group select option {
    padding: 8px 10px;
    font-weight: 500;
    background-color: #fff;
    color: #1e293b;
}

.filter-group select option:checked {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.filter-group select option:hover {
    background-color: #eef2ff;
}

/* Remove Button - Compact circle */
.remove-condition {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 50%;
    color: #94a3b8;
    font-size: 0.65rem;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.18s ease;
    z-index: 4;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.filter-condition:hover .remove-condition {
    opacity: 1;
    transform: scale(1);
}

.remove-condition:hover {
    color: #fff;
    background: #ef4444;
    border-color: #ef4444;
    transform: scale(1.08);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

/* Hide the old header container if present */
.chip-header {
    display: contents;
}

/* First condition styling */
.filter-condition:first-child .logical-operator-container {
    display: none;
}

/* First condition special badge */
.filter-condition:first-child::before {
    content: '★';
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.4);
}

/* Responsive adjustments - Stack on mobile */
@media (max-width: 768px) {
    #filterConditions {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .filter-condition {
        padding: 10px 12px;
    }
    
    .filter-group {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .filter-group select,
    .filter-group input {
        width: 100%;
        min-width: 0;
        height: 36px;
    }
    
    .filter-indicator, .filter-operator, .filter-value {
        flex: none;
        width: 100%;
    }
    
    .remove-condition {
        opacity: 1;
        transform: scale(1);
    }
}

/* Larger screens: 3-4 columns */
@media (min-width: 1100px) {
    #filterConditions {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1400px) {
    #filterConditions {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* --- Visual Polish --- */
/* Subtle left accent for signal type */
.condition-chip.chip-long { 
    border-left: 4px solid #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 50%);
}
.condition-chip.chip-long::before {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}

.condition-chip.chip-short { 
    border-left: 4px solid #f97373;
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 55%);
}
.condition-chip.chip-short::before {
    background: linear-gradient(135deg, #f97373 0%, #ef4444 100%);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
}

.condition-chip.chip-neutral { 
    border-left: 4px solid #9ca3af;
    background: linear-gradient(135deg, #f3f4f6 0%, #ffffff 55%);
}
.condition-chip.chip-neutral::before {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    box-shadow: 0 2px 6px rgba(107, 114, 128, 0.35);
}

/* Select coloring overrides */
.select-long { 
    color: #047857 !important; 
    font-weight: 600; 
    background: linear-gradient(145deg, #ecfdf5 0%, #f0fdf4 100%) !important;
    border-color: #6ee7b7 !important;
}
.select-short { 
    color: #b91c1c !important; 
    font-weight: 600; 
    background: linear-gradient(145deg, #fef2f2 0%, #fee2e2 100%) !important;
    border-color: #fecaca !important;
}
.select-neutral { 
    color: #4b5563 !important; 
    font-weight: 600; 
    background: linear-gradient(145deg, #f3f4f6 0%, #e5e7eb 100%) !important;
    border-color: #d1d5db !important;
} 