/* ===== FANTACALCIO AUCTION - CSS COMPLETO FINALE ===== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-blue: #4F63D2;
    --primary-green: #10B981;
    --primary-orange: #FF8A4C;
    --primary-pink: #FF6B9D;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --white: #FFFFFF;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --transition: all 0.2s ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
}

/* ===== CONTAINER PRINCIPALE ===== */
#fantacalcio-simple-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 20px;
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
}

/* ===== HEADER ===== */
#fantacalcio-simple-container h2 {
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 30px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-pink));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ===== SEZIONE UTENTE - DESIGN PULITO ===== */
.user-section {
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-orange));
    border-radius: var(--border-radius-lg);
    padding: 30px;
    margin-bottom: 20px;
}

.user-section h3 {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* ===== SELECT GIOCATORE ===== */
.player-selection {
    margin-bottom: 20px;
}

.player-selection label {
    display: block;
    color: var(--white);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-wrapper {
    position: relative;
}

.player-selection select {
    width: 100%;
    padding: 12px 16px;
    background: var(--white);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-700);
    appearance: none;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.player-selection select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(79, 99, 210, 0.1);
}

.select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
    font-size: 0.8rem;
}

/* ===== LAYOUT IMPORTO - COME NELL'IMMAGINE ===== */
.bid-input {
    margin-bottom: 20px;
}

.bid-input label {
    display: block;
    color: var(--white);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Container orizzontale come nell'immagine */
.amount-container {
    display: flex;
    align-items: center;
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 4px;
    box-shadow: var(--shadow);
    gap: 8px;
}

/* Simbolo Euro */
.euro-symbol {
    background: var(--primary-green);
    color: var(--white);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Input numero */
.bid-input input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-700);
    text-align: center;
    font-family: 'Inter', monospace;
}

.bid-input input:focus {
    outline: none;
}

.bid-input input::placeholder {
    color: var(--gray-400);
    font-weight: 400;
}

/* Bottone azione */
.action-button {
    background: linear-gradient(135deg, var(--primary-blue), #6366F1);
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 99, 210, 0.4);
}

.action-button:disabled {
    background: var(--gray-300);
    color: var(--gray-500);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Info range sotto l'input */
.amount-info {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
    text-align: center;
    margin-top: 8px;
    font-style: italic;
}

/* ===== SEZIONE ADMIN - DESIGN MODERNO ===== */
.admin-section {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 30px;
}

.admin-section h3 {
    color: var(--gray-900);
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.admin-section h4 {
    color: var(--gray-700);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 20px 0 15px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Controls admin */
.admin-controls {
    display: grid;
    gap: 25px;
}

.refresh-section {
    text-align: center;
}

.btn-refresh {
    background: linear-gradient(135deg, var(--primary-blue), #6366F1);
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.btn-refresh:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Lista offerte */
.bids-list-section {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 20px;
    border: 1px solid var(--gray-200);
}

#bids-list {
    max-height: 400px;
    overflow-y: auto;
}

#bids-list::-webkit-scrollbar {
    width: 6px;
}

#bids-list::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 3px;
}

#bids-list::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

#bids-list::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Card offerta */
.bid-item {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 12px;
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}

.bid-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.bid-item:last-child {
    margin-bottom: 0;
}

.bid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.bid-fantasq {
    font-weight: 700;
    color: var(--gray-900);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bid-amount {
    font-weight: 800;
    color: var(--primary-green);
    font-size: 1.2rem;
    font-family: 'Inter', monospace;
}

/* Status offerta (sostituisce l'importo per admin) */
.bid-status {
    background: var(--primary-green);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bid-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.bid-player {
    color: var(--gray-600);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bid-time {
    color: var(--gray-400);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Badge migliore offerta */
.best-bid {
    border-color: var(--primary-green);
    background: linear-gradient(135deg, #F0FDF4, #ECFDF5);
}

.best-bid .bid-fantasq::after {
    content: '👑 BEST';
    background: var(--primary-green);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 8px;
}

/* Assign section */
.assign-section {
    text-align: center;
}

.btn-assign {
    background: linear-gradient(135deg, var(--primary-green), #059669);
    color: var(--white);
    border: none;
    padding: 14px 28px;
    border-radius: var(--border-radius);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-assign:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-assign:disabled {
    background: var(--gray-300) !important;
    color: var(--gray-500) !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* ===== MESSAGGI ===== */
#bid-messages,
#admin-messages {
    margin-top: 20px;
}

.message-success {
    background: linear-gradient(135deg, var(--primary-green), #059669);
    color: var(--white);
    padding: 16px 20px;
    border-radius: var(--border-radius);
    margin: 12px 0;
    text-align: center;
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease-out;
}

.message-error {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: var(--white);
    padding: 16px 20px;
    border-radius: var(--border-radius);
    margin: 12px 0;
    text-align: center;
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease-out;
}

.message-info {
    background: linear-gradient(135deg, var(--primary-blue), #6366F1);
    color: var(--white);
    padding: 16px 20px;
    border-radius: var(--border-radius);
    margin: 12px 0;
    text-align: center;
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Messaggio persistente con bottone chiusura */
.persistent-message {
    position: relative;
    padding: 20px 60px 20px 20px; /* Spazio extra per il bottone */
    text-align: left;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.persistent-message .message-content {
    font-size: 1.1rem;
    line-height: 1.5;
    padding-right: 10px;
}

.close-message-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.close-message-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.close-message-btn:active {
    transform: scale(0.95);
}

/* ===== TABELLA OFFERTE ===== */
.bids-table-container {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    margin-top: 30px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
}

.bids-table-container h4 {
    color: var(--gray-900);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--gray-100);
}

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

.bids-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.bids-table thead {
    background: linear-gradient(135deg, var(--primary-blue), #6366F1);
    color: var(--white);
}

.bids-table th {
    padding: 15px 12px;
    text-align: left;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bids-table td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-100);
    font-weight: 500;
}

.bids-table tbody tr {
    transition: var(--transition);
}

.bids-table tbody tr:hover {
    background: var(--gray-50);
}

.bids-table tbody tr:last-child td {
    border-bottom: none;
}

/* Riga vincitore */
.winner-row {
    background: linear-gradient(135deg, #F0FDF4, #DCFCE7) !important;
    border-left: 5px solid var(--primary-green);
}

.winner-row:hover {
    background: linear-gradient(135deg, #ECFDF5, #D1FAE5) !important;
}

/* Celle specifiche */
.fantasq-cell {
    font-weight: 700;
    color: var(--gray-900);
    font-size: 1rem;
}

.winner-row .fantasq-cell {
    color: var(--primary-green);
    font-weight: 800;
}

.player-cell {
    color: var(--gray-700);
    font-weight: 600;
}

.amount-cell {
    color: var(--primary-green);
    font-weight: 800;
    font-family: 'Inter', monospace;
    font-size: 1.1rem;
    text-align: right;
}

.date-cell,
.time-cell {
    color: var(--gray-500);
    font-size: 0.9rem;
    text-align: center;
}

/* Azioni tabella */
.table-actions {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid var(--gray-100);
}

.close-table-btn {
    background: linear-gradient(135deg, var(--gray-600), var(--gray-700));
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

.close-table-btn:hover {
    background: linear-gradient(135deg, var(--gray-700), var(--gray-800));
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.close-table-btn:disabled {
    background: var(--gray-300) !important;
    color: var(--gray-500) !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    #fantacalcio-simple-container {
        margin: 20px;
        padding: 16px;
    }

    .user-section,
    .admin-section {
        padding: 20px;
    }

    .amount-container {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px;
    }

    .euro-symbol {
        width: 100%;
        height: 48px;
    }

    .action-button {
        width: 100%;
        padding: 16px;
        font-size: 1rem;
    }

    .bid-header,
    .bid-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .bid-amount {
        align-self: flex-end;
    }

    /* Responsive per messaggio persistente */
    .persistent-message {
        padding: 15px 15px 60px 15px; /* Spazio sotto per il bottone */
        text-align: center;
    }

    .close-message-btn {
        position: static;
        margin-top: 15px;
        width: 100%;
        padding: 12px;
    }

    /* Responsive per tabella offerte */
    .bids-table-container {
        padding: 15px;
        margin-top: 20px;
    }

    .bids-table-container h4 {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }

    .bids-table th,
    .bids-table td {
        padding: 8px 6px;
        font-size: 0.85rem;
    }

    .bids-table th {
        font-size: 0.75rem;
    }

    .amount-cell {
        font-size: 0.9rem;
    }

    .close-table-btn {
        width: 100%;
        padding: 14px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .user-section,
    .admin-section {
        padding: 16px;
    }

    .bid-item {
        padding: 16px;
    }

    .bids-table-container {
        padding: 12px;
    }

    .table-wrapper {
        font-size: 0.8rem;
    }
}

/* ===== LOADING STATES ===== */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== ACCESSIBILITÀ ===== */
.action-button:focus,
.btn-refresh:focus,
.btn-assign:focus,
.close-table-btn:focus,
.player-selection select:focus,
.bid-input input:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Riduzione movimento per utenti sensibili */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .action-button:hover,
    .btn-refresh:hover,
    .btn-assign:hover,
    .close-table-btn:hover,
    .bid-item:hover {
        transform: none;
    }
}

/* ===== ANIMAZIONI SPECIALI ===== */
.celebration {
    animation: celebrate 1s ease-in-out;
}

@keyframes celebrate {
    0%, 100% { 
        transform: scale(1) rotate(0deg); 
    }
    25% { 
        transform: scale(1.05) rotate(1deg); 
    }
    75% { 
        transform: scale(1.05) rotate(-1deg); 
    }
}

/* Errori generali */
.auction-error {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: var(--white);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 600;
    box-shadow: var(--shadow);
    margin: 20px 0;
}

/* ===== UTILITÀ ===== */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== PRINT STYLES ===== */
@media print {
    * {
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
    }
    
    #fantacalcio-simple-container {
        box-shadow: none;
        border: 1px solid #000;
        margin: 0;
        padding: 20px;
    }
    
    .user-section,
    .admin-section {
        background: transparent !important;
        border: 1px solid #000;
    }
    
    .action-button,
    .btn-refresh,
    .btn-assign,
    .close-table-btn {
        display: none;
    }
    
    .bids-table {
        border: 1px solid #000;
    }
    
    .bids-table th,
    .bids-table td {
        border: 1px solid #000;
    }
}