/* ======================================== */
/* CONTROL SECTIONS */
/* ======================================== */
.control-section {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    animation: fadeIn 0.5s var(--ease-standard);
    animation-fill-mode: both;
}

.control-section:nth-child(1) { animation-delay: 0.1s; }
.control-section:nth-child(2) { animation-delay: 0.2s; }
.control-section:nth-child(3) { animation-delay: 0.3s; }
.control-section:nth-child(4) { animation-delay: 0.4s; }
.control-section:nth-child(5) { animation-delay: 0.5s; }

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.control-section label {
    display: block;
    font-weight: 600;
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-md);
    color: var(--color-text);
    letter-spacing: 0.01em;
    transition: color var(--transition-fast);
}

.control-section h3 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-md);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ======================================== */
/* FORM CONTROLS */
/* ======================================== */
select,
input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    background: white;
    transition: all var(--transition-base);
    font-family: inherit;
    appearance: none;
    cursor: pointer;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2321808D' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

select:hover,
input[type="number"]:hover {
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(33, 128, 141, 0.05);
}

select:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(33, 128, 141, 0.1);
    transform: translateY(-1px);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

input[type="number"]:hover::-webkit-inner-spin-button,
input[type="number"]:hover::-webkit-outer-spin-button {
    opacity: 1;
}

/* ======================================== */
/* BUTTON GRID */
/* ======================================== */
.btn-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

/* ======================================== */
/* BUTTONS */
/* ======================================== */
.btn-filter,
.btn-action {
    position: relative;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    background: white;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition-base);
    overflow: hidden;
    letter-spacing: 0.01em;
}

.btn-filter::before,
.btn-action::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(33, 128, 141, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-filter:active::before,
.btn-action:active::before {
    width: 300px;
    height: 300px;
}

.btn-filter:hover,
.btn-action:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-filter:active,
.btn-action:active {
    transform: translateY(0);
}

.btn-filter.active {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--color-primary);
    box-shadow: var(--shadow);
}

.btn-filter.active:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-action {
    width: 100%;
    margin-bottom: var(--space-sm);
    background: linear-gradient(135deg, white 0%, var(--color-bg) 100%);
}

.btn-action:last-child {
    margin-bottom: 0;
}

.btn-action:hover {
    background: var(--color-bg);
}

/* Primary action button variant */
.btn-action-primary {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--color-primary);
}

.btn-action-primary:hover {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-lg);
}

/* ======================================== */
/* RANGE CONTROLS */
/* ======================================== */
.range-controls {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    animation: fadeIn 0.4s var(--ease-standard);
}

.range-controls input {
    flex: 1;
}

.range-controls span {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    font-weight: 500;
    padding: 0 var(--space-xs);
}

/* ======================================== */
/* METRIC SELECT WRAPPER */
/* ======================================== */
.metric-select-wrapper {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: var(--space-sm);
}

.metric-select-wrapper select {
    flex: 1;
}

/* ======================================== */
/* LOADING STATE */
/* ======================================== */
.btn-filter.loading,
.btn-action.loading {
    pointer-events: none;
    opacity: 0.6;
    position: relative;
}

.btn-filter.loading::after,
.btn-action.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ======================================== */
/* RESPONSIVE - CONTROLS */
/* ======================================== */
@media (max-width: 768px) {
    .btn-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.375rem;
    }
    
    .btn-filter,
    .btn-action {
        padding: 0.625rem 0.5rem;
        font-size: var(--font-size-xs);
    }
    
    .control-section {
        margin-bottom: var(--space-md);
        padding-bottom: var(--space-md);
    }
}

@media (max-width: 480px) {
    .btn-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    select,
    input[type="number"] {
        padding: 0.625rem;
        font-size: var(--font-size-xs);
    }
    
    .range-controls {
        flex-wrap: wrap;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn-filter,
    .btn-action {
        min-height: 44px; /* Apple's recommended touch target size */
        padding: 0.75rem;
    }
    
    select,
    input[type="number"] {
        min-height: 44px;
    }
}
