﻿/**
 * Fix Allineamento Perfetto Card Oroscopi
 * File: static/css/horoscope-alignment-fix.css
 * 
 * Risolve il problema dei pulsanti disallineati impostando altezze fisse
 */

/* ===== FIX PRINCIPALE: ALTEZZE FISSE ===== */

.horoscope-card {
    display: flex !important;
    flex-direction: column !important;
    height: 550px !important; /* Altezza fissa per tutte le card */
    min-height: 550px !important;
    max-height: 550px !important;
}

/* ===== HEADER: ALTEZZA FISSA ===== */

.card-header {
    flex-shrink: 0 !important; /* Non si riduce mai */
    height: 160px !important; /* Altezza fissa */
    min-height: 160px !important;
    max-height: 160px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 1.5rem 1rem !important;
}

/* ===== BODY: ALTEZZA CONTROLLATA ===== */

.card-body {
    flex: 1 !important; /* Prende tutto lo spazio disponibile */
    display: flex !important;
    flex-direction: column !important;
    padding: 1.5rem !important;
    overflow: hidden !important; /* Importante: nasconde overflow */
    min-height: 200px !important;
    max-height: 200px !important; /* Altezza massima fissa */
}

/* ===== PREVIEW: ALTEZZA FISSA E CONTROLLO OVERFLOW ===== */

.horoscope-preview {
    flex: 1 !important; /* Prende tutto lo spazio del body */
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    
    /* Imposta altezza fissa per il contenuto del preview */
    height: 140px !important;
    min-height: 140px !important;
    max-height: 140px !important;
    
    /* Multi-line text truncation */
    display: -webkit-box !important;
    -webkit-line-clamp: 6 !important; /* Massimo 6 righe */
    -webkit-box-orient: vertical !important;
    
    line-height: 1.6 !important;
    font-size: 0.95rem !important;
    color: #444 !important;
    margin-bottom: 1rem !important;
    
    /* Gradiente per fade-out del testo */
    position: relative !important;
}

/* Effetto fade-out alla fine del testo */
.horoscope-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, rgba(255, 255, 255, 0.9));
    pointer-events: none;
}

/* ===== FOOTER: ALTEZZA FISSA ===== */

.card-footer {
    flex-shrink: 0 !important; /* Non si riduce mai */
    height: 190px !important; /* Altezza fissa per footer */
    min-height: 190px !important;
    max-height: 190px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    padding: 1.5rem !important;
    border-top: 1px solid rgba(107, 63, 160, 0.1) !important;
    background: linear-gradient(135deg, #f8f9fa, #ffffff) !important;
}

/* ===== META SECTION: ALTEZZA CONTROLLATA ===== */

.horoscope-meta {
    flex-shrink: 0 !important;
    height: 300px !important; /* Altezza fissa per i meta */
    min-height: 300px !important;
    max-height: 300px !important;
    display: grid !important;
    grid-template-columns: repeat(1, 1fr) !important;
    gap: 0.75rem !important;
    margin-bottom: 1rem !important;
    padding: 0.75rem !important;
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
    border: 1px solid rgba(107, 63, 160, 0.1) !important;
    overflow: hidden !important;
}

.meta-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 0.5rem 0.25rem !important;
    background: linear-gradient(135deg, #f8f9fa, #ffffff) !important;
    border-radius: 8px !important;
    height: 100% !important;
    overflow: hidden !important;
}

.meta-label {
    font-size: 0.75rem !important;
    color: #666 !important;
    margin-bottom: 0.25rem !important;
    font-weight: 500 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    line-height: 1.2 !important;
}

.meta-value {
    font-weight: 700 !important;
    font-size: 1rem !important;
    line-height: 1.2 !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
}

/* ===== ACTIONS: ALTEZZA FISSA ===== */

.card-actions {
    flex-shrink: 0 !important;
    height: 50px !important; /* Altezza fissa per i pulsanti */
    min-height: 50px !important;
    max-height: 50px !important;
    display: grid !important;
    grid-template-columns: 2fr 1fr !important;
    gap: 1rem !important;
    align-items: center !important;
}

.btn-small {
    height: 44px !important; /* Altezza fissa per i pulsanti */
    min-height: 44px !important;
    max-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 1.5rem !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    border-radius: 10px !important;
    text-decoration: none !important;
    text-align: center !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    overflow: hidden !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

/* ===== RESPONSIVE: ALTEZZE ADATTIVE ===== */

@media (max-width: 1200px) {
    .horoscope-card {
        height: 520px !important;
        min-height: 520px !important;
        max-height: 520px !important;
    }
    
    .card-header {
        height: 150px !important;
        min-height: 150px !important;
        max-height: 150px !important;
    }
    
    .card-body {
        max-height: 190px !important;
    }
    
    .horoscope-preview {
        height: 130px !important;
        max-height: 130px !important;
        -webkit-line-clamp: 5 !important;
    }
    
    .card-footer {
        height: 180px !important;
        min-height: 180px !important;
        max-height: 180px !important;
    }
}

@media (max-width: 768px) {
    .horoscope-card {
        height: 480px !important;
        min-height: 480px !important;
        max-height: 480px !important;
        margin: 0 0.5rem 1.5rem !important;
    }
    
    .card-header {
        height: 130px !important;
        min-height: 130px !important;
        max-height: 130px !important;
        padding: 1rem !important;
    }
    
    .card-header h2 {
        font-size: 1.5rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .sign-icon {
        width: 45px !important;
        height: 45px !important;
        margin-bottom: 0.5rem !important;
    }
    
    .card-body {
        max-height: 170px !important;
        padding: 1rem !important;
    }
    
    .horoscope-preview {
        height: 110px !important;
        max-height: 110px !important;
        font-size: 0.9rem !important;
        -webkit-line-clamp: 4 !important;
    }
    
    .card-footer {
        height: 180px !important;
        min-height: 180px !important;
        max-height: 180px !important;
        padding: 1rem !important;
    }
    
    .horoscope-meta {
        grid-template-columns: 1fr !important;
        height: 120px !important;
        max-height: 120px !important;
        gap: 0.5rem !important;
        padding: 0.5rem !important;
    }
    
    .meta-item {
        flex-direction: row !important;
        justify-content: space-between !important;
        text-align: left !important;
        padding: 0.5rem !important;
        height: auto !important;
        min-height: 35px !important;
    }
    
    .card-actions {
        grid-template-columns: 1fr !important;
        height: 44px !important;
        gap: 0 !important;
    }
    
    .btn-small {
        width: 100% !important;
        margin-bottom: 0 !important;
    }
    
    .btn-outline.btn-small {
        display: none !important; /* Nascondi il bottone condividi su mobile per risparmiare spazio */
    }
}

@media (max-width: 480px) {
    .horoscope-card {
        height: 450px !important;
        min-height: 450px !important;
        max-height: 450px !important;
        margin: 0 0 1rem !important;
    }
    
    .card-header {
        height: 120px !important;
        min-height: 120px !important;
        max-height: 120px !important;
        padding: 0.75rem !important;
    }
    
    .card-header h2 {
        font-size: 1.3rem !important;
    }
    
    .sign-icon {
        width: 40px !important;
        height: 40px !important;
    }
    
    .card-body {
        max-height: 150px !important;
        padding: 0.75rem !important;
    }
    
    .horoscope-preview {
        height: 100px !important;
        max-height: 100px !important;
        font-size: 0.85rem !important;
        -webkit-line-clamp: 4 !important;
    }
    
    .card-footer {
        height: 180px !important;
        min-height: 180px !important;
        max-height: 180px !important;
        padding: 0.75rem !important;
    }
    
    .horoscope-meta {
        height: 130px !important;
        max-height: 130px !important;
    }
    
    .meta-item {
        min-height: 38px !important;
    }
    
    .meta-label {
        font-size: 0.7rem !important;
    }
    
    .meta-value {
        font-size: 0.9rem !important;
    }
}

/* ===== FIX READ-more LINK ===== */

.read-more {
    position: absolute !important;
    bottom: 0 !important;
    right: 0 !important;
    background: linear-gradient(135deg, rgba(107, 63, 160, 0.9), rgba(107, 63, 160, 0.8)) !important;
    color: white !important;
    padding: 0.25rem 0.75rem !important;
    border-radius: 12px 0 0 0 !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    z-index: 10 !important;
    backdrop-filter: blur(10px) !important;
}

.read-more:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    color: white !important;
    text-decoration: none !important;
    transform: scale(1.05) !important;
}

/* ===== OVERRIDE STILI ESISTENTI CHE POTREBBERO CONFLITTARE ===== */

.grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)) !important;
    gap: 2rem !important;
    align-items: stretch !important;
    padding: 2rem 0 !important;
}

/* Forza tutte le card alla stessa altezza nel grid */
.grid .horoscope-card {
    align-self: stretch !important;
}

/* ===== DEBUG HELPERS (decommentare per verificare allineamento) ===== */

/*
.card-header { border: 2px solid red !important; }
.card-body { border: 2px solid blue !important; }
.card-footer { border: 2px solid green !important; }
.horoscope-preview { border: 1px solid orange !important; }
.horoscope-meta { border: 1px solid purple !important; }
.card-actions { border: 1px solid brown !important; }
*/
