/* ============================================
   FRAMEWORK DE ANUNCIOS - DOMIDELIS
   1. App del Cliente (Tarjetas y Pop-up)
   2. Panel de Administración
   3. Constructor Visual (Drag & Drop y Preview)
   ============================================ */

/* ============================================
   1. APP DEL CLIENTE (TARJETAS Y POP-UP)
   ============================================ */

/* Contenedor de tarjetas en index.html */
#contenedor-anuncios {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

/* Tarjeta de Anuncio (Category Card) */
.anuncio-card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0,0,0,0.05);
    cursor: pointer;
}

.anuncio-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.anuncio-card-img {
    height: 180px;
    background-size: cover;
    background-position: center;
    background-color: var(--light);
    position: relative;
}

.anuncio-badge-card {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--primary);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.anuncio-card-content {
    padding: 1.2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.anuncio-card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.3rem;
}

.anuncio-card-subtitle {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 1rem;
}

.anuncio-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
}

.anuncio-card-price {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
}

.anuncio-card-price small {
    text-decoration: line-through;
    color: var(--gray);
    font-weight: 400;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.anuncio-card-btn {
    background: var(--dark);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.anuncio-card-btn:hover {
    background: var(--primary);
}

/* Pop-up Modal (Elegante y bloqueado) */
.anuncio-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.anuncio-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.popup-anuncio {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.anuncio-popup-overlay.active .popup-anuncio {
    transform: scale(1);
}

.popup-header-bar {
    height: 6px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), #FFD23F);
    flex-shrink: 0;
}

.popup-cerrar {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #333;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.popup-cerrar:hover {
    background: var(--primary);
    color: white;
    transform: rotate(90deg);
}

.popup-imagen-wrap {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--light) 0%, #ffeaa7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.popup-imagen-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.popup-emoji-grande {
    font-size: 5rem;
}

.popup-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, var(--primary), #c0392b);
    color: #fff;
    padding: 5px 14px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.4);
}

.popup-contenido {
    padding: 20px 24px 24px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-y: auto;
}

.popup-contenido h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.popup-subtitulo {
    font-size: 12px;
    color: var(--secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.popup-contenido p {
    font-size: 14px;
    color: #555;
    line-height: 1.4;
    margin: 0;
}

.popup-precio {
    font-size: 26px;
    font-weight: 700;
    color: var(--accent);
    margin: 12px 0 10px 0;
}

.popup-precio span {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
    margin-left: 8px;
    font-weight: 400;
}

.popup-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--dark), var(--secondary));
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    padding: 14px 20px;
    border-radius: 50px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 8px 25px rgba(93, 64, 55, 0.35);
    transition: all 0.3s ease;
    margin-top: 10px;
}

.popup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(93, 64, 55, 0.45);
}

.popup-input-codigo {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    text-align: center;
    font-size: 16px;
    letter-spacing: 2px;
    font-weight: 600;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.2s;
}

.popup-input-codigo:focus {
    border-color: var(--primary);
}

.popup-nota {
    margin-top: 10px;
    font-size: 11px;
    color: #aaa;
}


/* ============================================
   2. PANEL DE ADMINISTRACIÓN
   ============================================ */

.admin-anuncios-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.tipos-anuncio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.tipo-anuncio-card {
    background: var(--white);
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.tipo-anuncio-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.tipo-anuncio-card i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.tipo-anuncio-card h4 {
    font-size: 1.1rem;
    color: var(--dark);
    margin-bottom: 0.3rem;
}

.tipo-anuncio-card p {
    font-size: 0.85rem;
    color: var(--gray);
}

/* Calculadora de Presupuesto */
.calculadora-presupuesto {
    background: linear-gradient(135deg, #fff8e7, #fffcf0);
    border: 1px solid var(--secondary);
    border-radius: var(--border-radius-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.calculadora-presupuesto h5 {
    color: var(--dark);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calc-input-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.calc-input-group input {
    flex: 1;
    padding: 0.8rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 700;
}

.calc-resultado {
    background: var(--white);
    padding: 1rem;
    border-radius: 10px;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--dark);
    border-left: 4px solid var(--accent);
}

/* ============================================
   3. CONSTRUCTOR VISUAL (DRAG & DROP Y PREVIEW)
   ============================================ */

.constructor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .constructor-layout {
        grid-template-columns: 1fr;
    }
}

.constructor-form {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

/* Lista de elementos arrastrables (Drag & Drop) */
.drag-list {
    margin: 1.5rem 0;
    border: 2px dashed #e0e0e0;
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    background: var(--light);
}

.drag-item {
    background: var(--white);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: grab;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.drag-item:active {
    cursor: grabbing;
}

.drag-item.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.drag-handle {
    color: var(--gray);
    font-size: 1.2rem;
}

.drag-item-text {
    font-weight: 500;
    color: var(--dark);
    text-transform: capitalize;
}

/* Marco de Preview (Simulando Teléfono) */
.preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--light);
    padding: 2rem;
    border-radius: var(--border-radius);
    position: sticky;
    top: 2rem;
}

.preview-device-frame {
    width: 100%;
    max-width: 320px;
    background: var(--white);
    border: 8px solid var(--dark);
    border-radius: 30px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    min-height: 400px;
}

.preview-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.preview-element {
    background: var(--light);
    border-radius: 8px;
    overflow: hidden;
    transition: opacity 0.2s;
}

.preview-element.img-placeholder {
    height: 120px;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray);
}

.preview-element.title-placeholder {
    height: 24px;
    background: var(--dark);
    width: 80%;
    margin: 0 auto;
}

.preview-element.text-placeholder {
    height: 16px;
    background: var(--gray);
    width: 100%;
}

.preview-element.price-placeholder {
    height: 28px;
    background: var(--primary);
    width: 50%;
    margin: 0 auto;
}

.preview-element.btn-placeholder {
    height: 40px;
    background: var(--secondary);
    width: 100%;
    border-radius: 20px;
}

/* Badges de estado en la tabla del admin */
.badge-estado-anuncio {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-activo { background: var(--success); color: white; }
.badge-borrador { background: var(--gray); color: white; }
.badge-vencido { background: var(--danger); color: white; }
.badge-programado { background: var(--info); color: white; }