/* ============================================
   Modal
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

/* Modals that open on top of other modals need higher z-index */
#sendWorkRequestModal.modal {
    z-index: 1100;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

.modal-content {
    position: relative;
    z-index: 1;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
}

.modal-small {
    width: 560px;
    max-width: 95vw;
    padding: 28px;
}

.modal-small h2 {
    margin-bottom: 20px;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    z-index: 10;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--error);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

/* Photo Modal */
.photo-modal-content {
    display: flex;
    width: 90vw;
    max-width: 1200px;
    height: 85vh;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.photo-modal-image {
    flex: 1;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0;
}

.photo-modal-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.2s ease;
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 2rem;
    transition: background 0.2s;
}

.nav-arrow:hover {
    background: var(--primary);
}

.nav-prev {
    left: 16px;
}

.nav-next {
    right: 16px;
}

.photo-modal-info {
    width: 340px;
    padding: 28px 24px;
    overflow-y: auto;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
}

.photo-modal-info h2 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    word-break: break-word;
    padding-right: 28px;
}

.photo-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.meta-item {
    margin-bottom: 8px;
}

.meta-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.meta-value {
    font-size: 0.9rem;
}

.photo-description p,
.photo-tags {
    font-size: 0.9rem;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.tag {
    background: var(--bg-hover);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* Tags iluminados en el modal fullscreen */
.tags-list .search-tag {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
}

/* Cart button in photo modal */
.modal-cart-action {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.modal-cart-action .btn {
    width: 100%;
    justify-content: center;
}

.tags-list .search-tag-match {
    background: var(--success-light);
    color: #047857;
}

.tags-list .search-tag-dim {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ============================================
   Pagination
   ============================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.btn-page {
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-page:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================
   Toast
   ============================================ */

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
    color: white;
}

.toast.error {
    background: var(--error);
    color: white;
}

.toast.info {
    background: var(--primary);
    color: white;
}

.toast.warning {
    background: var(--warning);
    color: #000;
}

/* ============================================
   Loading
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Aviso mientras llega una foto grande (visor y pantalla completa, fondo oscuro) */
.foto-cargando {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--primary-text);
    font-size: 0.9rem;
    pointer-events: none;
}

.foto-cargando[hidden] {
    display: none;
}

/* un botón que no se puede pulsar no se enseña */
button[hidden] {
    display: none !important;
}

.foto-cargando .spinner {
    width: 40px;
    height: 40px;
    border-color: rgba(255, 255, 255, 0.25);
    border-top-color: var(--primary-text);
}

.foto-oculta {
    visibility: hidden;
}


/* Texto de ayuda bajo un campo de formulario */
.form-hint { display: block; margin-top: 4px; font-size: 0.78rem; color: var(--text-muted); }
