/* ===== HTMX Loading Indicators ===== */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

.htmx-request {
    position: relative;
}

.htmx-request::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 1rem;
    width: 1rem;
    height: 1rem;
    margin-top: -0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: #0ea5e9;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ===== Toast Notifications ===== */
.toast {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    color: white;
    font-weight: 500;
    animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-in 4.7s forwards;
    max-width: 90vw;
}

.toast.success {
    background-color: #10b981;
}

.toast.error {
    background-color: #ef4444;
}

.toast.info {
    background-color: #0ea5e9;
}

.toast.warning {
    background-color: #f59e0b;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ===== Focus States for Accessibility ===== */
button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #0ea5e9;
    outline-offset: 2px;
}

/* ===== Mobile Touch Improvements ===== */
@media (max-width: 768px) {
    button,
    a,
    input[type="button"],
    input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }

    button,
    .btn {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
}

/* ===== Custom Utilities ===== */
.btn-primary {
    background-color: #0ea5e9;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #0284c7;
}

.btn-primary:disabled {
    background-color: #475569;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: background-color 0.2s;
    border: 1px solid #334155;
}

.btn-secondary:hover {
    background-color: #334155;
}

.card {
    background-color: #1e293b;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border: 1px solid #334155;
}

/* ===== Infinite Scroll Loading ===== */
.infinite-scroll-trigger {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Form Enhancements ===== */
input[type="text"],
input[type="search"],
textarea,
select {
    font-size: 16px; /* Prevents zoom on iOS */
}

/* ===== Responsive Grid ===== */
.media-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .media-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .media-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

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