/* ================================ */
/* ADD RACE DROPDOWN STYLES */
/* ================================ */

/* Dropdown container */
.add-race-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    min-width: 320px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
    box-sizing: border-box;
}

.add-race-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Theme support */
body.theme .add-race-dropdown {
    background: rgba(26, 32, 44, 0.98);
    border-color: rgba(74, 85, 104, 0.5);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* Dropdown header */
.dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body.theme .dropdown-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.dropdown-header h4 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #2d3748;
}

body.theme .dropdown-header h4 {
    color: #e2e8f0;
}

.dropdown-close {
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: #718096;
    cursor: pointer;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.dropdown-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #2d3748;
}

body.theme .dropdown-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

/* Dropdown content */
.dropdown-content {
    display: flex;
    flex-direction: column;
    max-height: min(70vh, 700px);
}

.dropdown-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
    /* Prevent scroll from affecting parent */
    overscroll-behavior: contain;
    /* Custom scrollbar for better aesthetics */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.dropdown-form::-webkit-scrollbar {
    width: 6px;
}

.dropdown-form::-webkit-scrollbar-track {
    background: transparent;
}

.dropdown-form::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.dropdown-form:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
}

body.theme .dropdown-form::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

body.theme .dropdown-form:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
}

/* Form inputs */
.dropdown-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dropdown-input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #4a5568;
}

body.theme .dropdown-input-group label {
    color: #cbd5e0;
}

.dropdown-input-group input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
    transition: all 0.2s ease;
}

body.theme .dropdown-input-group input {
    background: rgba(45, 55, 72, 0.5);
    border-color: rgba(74, 85, 104, 0.5);
    color: #e2e8f0;
}

.dropdown-input-group input:focus {
    outline: none;
    border-color: #5a67d8;
    box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.1);
}

.dropdown-input-group input:invalid {
    border-color: #e53e3e;
}

/* Position buttons grid */
.position-buttons-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.position-btn {
    padding: 0.5rem;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
}

body.theme .position-btn {
    background: rgba(45, 55, 72, 0.5);
    border-color: rgba(74, 85, 104, 0.5);
    color: #cbd5e0;
}

.position-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

body.theme .position-btn:hover {
    background: rgba(74, 85, 104, 0.5);
    border-color: rgba(113, 128, 150, 0.5);
}

.position-btn.selected {
    background: #5a67d8;
    border-color: #5a67d8;
    color: white;
}

body.theme .position-btn.selected {
    background: #5a67d8;
    border-color: #5a67d8;
    color: white;
}

/* Error message */
.dropdown-error {
    margin: 0 1.25rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: #fed7d7;
    border: 1px solid #fc8181;
    border-radius: 0.5rem;
    color: #c53030;
    font-size: 0.875rem;
    animation: shake 0.3s ease-in-out;
}

body.theme .dropdown-error {
    background: rgba(254, 178, 178, 0.1);
    border-color: rgba(252, 129, 129, 0.3);
    color: #fc8181;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Action buttons - sticky at bottom */
.dropdown-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin-top: auto;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

body.theme .dropdown-actions {
    background: rgba(26, 32, 44, 0.98);
    border-top-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

.dropdown-save-btn,
.dropdown-cancel-btn {
    flex: 1;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropdown-save-btn {
    background: #5a67d8;
    color: white;
}

.dropdown-save-btn:hover {
    background: #4c51bf;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(90, 103, 216, 0.3);
}

.dropdown-save-btn:active {
    transform: translateY(0);
}

.dropdown-save-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.dropdown-cancel-btn {
    background: #e2e8f0;
    color: #4a5568;
}

body.theme .dropdown-cancel-btn {
    background: rgba(74, 85, 104, 0.5);
    color: #e2e8f0;
}

.dropdown-cancel-btn:hover {
    background: #cbd5e0;
}

body.theme .dropdown-cancel-btn:hover {
    background: rgba(113, 128, 150, 0.5);
}

/* Success animation */
@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.dropdown-save-btn.success {
    background: #48bb78;
    animation: successPulse 0.5s ease;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .add-race-dropdown {
        min-width: 280px;
    }
    
    .dropdown-content {
        max-height: calc(85vh - 4rem);
    }
    
    .position-buttons-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Overlay for mobile */
.dropdown-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dropdown-overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    .dropdown-overlay {
        display: block;
        opacity: 0;
        pointer-events: none;
    }
    
    .dropdown-overlay.active {
        pointer-events: auto;
        opacity: 1;
    }
}
