/* =============================================
   1. VARIABLES DE DISEÑO (Design System)
   ============================================= */
:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-gray: #f8f9fa;
    --medium-gray: #e9ecef;
    --border-color: #dee2e6;
    --text-color-dark: #212529;
    --text-color-muted: #6c757d;

    --border-radius-md: 0.5rem;
    --border-radius-lg: 0.8rem;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.2s ease-in-out;
}

/* =============================================
   2. ESTILOS DE LA TABLA DE PRODUCTOS
   ============================================= */
#tabla-mis-productos {
    border-collapse: separate;
    border-spacing: 0 8px; /* Espacio vertical entre filas */
}

#tabla-mis-productos thead th {
    border: none;
    text-transform: uppercase;
    color: var(--text-color-muted);
    font-size: 0.8em;
    font-weight: 700;
}

#tabla-mis-productos tbody tr {
    background-color: #fff;
    box-shadow: var(--shadow-sm);
    border-radius: var(--border-radius-md);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

#tabla-mis-productos tbody tr:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    z-index: 2;
    position: relative;
}

#tabla-mis-productos td {
    border: none;
    padding: 1rem;
    vertical-align: middle;
}

#tabla-mis-productos td:first-child {
    border-top-left-radius: var(--border-radius-md);
    border-bottom-left-radius: var(--border-radius-md);
}

#tabla-mis-productos td:last-child {
    border-top-right-radius: var(--border-radius-md);
    border-bottom-right-radius: var(--border-radius-md);
}

/* =============================================
   3. ESTILOS DEL MODAL Y FORMULARIO
   ============================================= */
.modal-content {
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    border: none;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 1050;
    display: none; /* Se activa con JS */
    justify-content: center;
    align-items: center;
    border-radius: var(--border-radius-lg);
}

.form-control.is-invalid {
    border-color: var(--danger-color);
    background-image: none;
}

.invalid-feedback {
    display: block;
    font-weight: 500;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================
   4. PREVISUALIZACIÓN DE IMÁGENES
   ============================================= */
.image-preview-container {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    min-height: 150px;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: flex-start;
    transition: border-color var(--transition-speed);
}

.image-preview-container:hover {
    border-color: var(--primary-color);
}

.image-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    background-color: var(--light-gray);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-speed);
}

.image-preview-item:hover img {
    transform: scale(1.05);
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(33, 37, 41, 0.7);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    transition: background-color var(--transition-speed), transform var(--transition-speed);
}

.image-preview-item .remove-btn:hover {
    background-color: var(--danger-color);
    transform: scale(1.1);
}

.placeholder-text {
    color: var(--text-color-muted);
    font-size: 0.9em;
    text-align: center;
    width: 100%;
}

/* =============================================
   5. AJUSTES DEFINITIVOS PARA SELECT2
   ============================================= */

/* Oculta el select original que Django podría generar */
select#id_ciudad_origen {
    display: none !important;
}

/* Hace que el contenedor de Select2 parezca un input de texto normal */
.select2-container--bootstrap-5 .select2-selection--single {
    background-color: var(--bs-body-bg) !important;
    border: 1px solid var(--border-color) !important;
    min-height: calc(1.5em + 0.75rem + 2px) !important;
    padding: 0.375rem 0.75rem !important;
    align-items: center;
}

/* Oculta la flecha del dropdown para que no parezca un select */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    display: none !important;
}

/* Alinea el texto del placeholder verticalmente */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 1.5 !important;
}