/**
 * components.css v1.1.0
 * Reusable UI component styles
 */

/* ==================== PAGE LOADER ==================== */

.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.page-loader-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #374151;
    border-top-color: #eab308;
    border-radius: 50%;
    animation: loaderSpin 0.8s linear infinite;
}

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

/* ==================== FORMS ==================== */

/* Custom checkbox */
.custom-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #4b5563;
    border-radius: 0.25rem;
    background-color: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.custom-checkbox:hover {
    border-color: #eab308;
}

.custom-checkbox:checked {
    background-color: #eab308;
    border-color: #eab308;
}

.custom-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #111827;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.custom-checkbox:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.3);
}

/* Custom range slider */
.custom-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #374151;
    outline: none;
    cursor: pointer;
}

.custom-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #eab308;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.custom-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.custom-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #eab308;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.custom-range::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.custom-range::-moz-range-track {
    background: #374151;
    height: 4px;
    border-radius: 2px;
}

/* Audio progress slider (specialized) */
.audio-progress {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #eab308 var(--progress, 0%), #374151 var(--progress, 0%));
    outline: none;
    cursor: pointer;
}

.audio-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease;
}

.audio-progress::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

.audio-progress::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #374151;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active {
    background-color: #eab308;
}

.toggle-switch.active::after {
    transform: translateX(20px);
}

/* ==================== BADGES ==================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-primary {
    background-color: rgba(234, 179, 8, 0.25);
    color: #eab308;
}

.badge-success {
    background-color: rgba(34, 197, 94, 0.25);
    color: #22c55e;
}

.badge-error {
    background-color: rgba(239, 68, 68, 0.25);
    color: #ef4444;
}

.badge-info {
    background-color: rgba(59, 130, 246, 0.25);
    color: #3b82f6;
}

/* ==================== DROPDOWNS ==================== */

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    min-width: 12rem;
    background-color: #1f2937;
    border: 1px solid #374151;
    border-radius: 0.5rem;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #d1d5db;
    transition: all 0.15s ease;
    cursor: pointer;
}

.dropdown-item:hover {
    background-color: #374151;
    color: #f9fafb;
}

/* ==================== STATUS BADGES ==================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
}

/* ==================== DOWNLOAD CHECKBOX ==================== */

.download-permission-checkbox {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.download-permission-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.download-permission-checkbox .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: #1f2937;
    border: 2px solid #4b5563;
    border-radius: 4px;
    transition: all 0.2s;
}

.download-permission-checkbox:hover .checkmark {
    border-color: #22c55e;
}

.download-permission-checkbox input:checked ~ .checkmark {
    background-color: #22c55e;
    border-color: #22c55e;
}

.download-permission-checkbox .checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.download-permission-checkbox input:checked ~ .checkmark:after {
    display: block;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ==================== MOBILE RESPONSIVE ==================== */

@media (max-width: 640px) {
    .dropdown-menu {
        position: fixed;
        left: 1rem;
        right: 1rem;
        bottom: 5rem;
        top: auto;
        min-width: auto;
    }

    /* Mobile-friendly download menu */
    #download-menu {
        position: fixed !important;
        left: 16px !important;
        right: 16px !important;
        bottom: 80px !important;
        top: auto !important;
        width: calc(100% - 32px) !important;
        max-width: calc(100% - 32px) !important;
        min-width: auto !important;
        border-radius: 16px !important;
        z-index: 100 !important;
        margin: 0 !important;
        transform: none !important;
    }

    #download-menu::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
}
