/* ===== TOTO SFC PLUGIN STYLES ===== */

#toto-sfc-container {
    max-width: 100%;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#toto-sfc-container h3 {
    color: #23282d;
    margin-bottom: 20px;
    padding: 10px 15px;
    background: #f1f1f1;
    border-left: 4px solid #0073aa;
    border-radius: 4px;
}

/* ===== TABELLA PRINCIPALE ===== */
.toto-sfc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 6px;
    overflow: hidden;
}

.toto-sfc-table th {
    background: #0073aa;
    color: white;
    padding: 8px 4px;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    border-right: 1px solid rgba(255,255,255,0.2);
    position: sticky;
    top: 0;
    z-index: 10;
}

.toto-sfc-table th:last-child {
    border-right: none;
}

.toto-sfc-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid #e1e1e1;
    border-right: 1px solid #e1e1e1;
    vertical-align: middle;
}

/* Prima colonna (PARTITA) sempre allineata a sinistra */
.toto-sfc-table td:first-child {
    text-align: left;
    padding-left: 9px;
}

.toto-sfc-table th:first-child {
    text-align: left;
    padding-left: 15px;
}

.toto-sfc-table td:last-child {
    border-right: none;
}

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

.toto-sfc-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.toto-sfc-table tbody tr:hover {
    background-color: #f0f8ff;
    transition: background-color 0.2s ease;
}

/* ===== EVIDENZIAZIONE RIGA ATTIVA ===== */
.toto-sfc-table tbody tr.active-row {
    background-color: #e7f3ff !important;
    box-shadow: inset 0 0 0 2px #0073aa;
}

/* ===== COLONNA UTENTE ===== */
.user-column-header {
    background: #d63638 !important;
    position: relative;
}

.user-column-header::after {
    content: "★";
    position: absolute;
    top: 2px;
    right: 5px;
    font-size: 12px;
}

.user-column {
    background-color: #fff5f5;
}

.toto-sfc-table tbody tr:nth-child(even) .user-column {
    background-color: #ffeaea;
}

.toto-sfc-table tbody tr:hover .user-column {
    background-color: #ffe0e0;
}

/* ===== INPUT E SELECT ===== */
.fantasq-input {
    width: 40px;
    height: 40px;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    background: white;
    transition: all 0.2s ease;
}

.fantasq-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 5px rgba(0,115,170,0.3);
    outline: none;
}

.fantasq-input.error {
    border-color: #d63638;
    box-shadow: 0 0 5px rgba(214,54,56,0.3);
    animation: shake 0.5s ease-in-out;
}

.fantasq-input.saved-highlight {
    border-color: #46b450;
    box-shadow: 0 0 8px rgba(70,180,80,0.4);
    animation: pulse-green 1s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes pulse-green {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.risultato-select {
    width: 60px;
    height: 36px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.risultato-select:focus {
    border-color: #0073aa;
    outline: none;
}

.readonly-cell {
    color: #999;
    font-style: italic;
}

/* ===== AZIONI FORM ===== */
.form-actions {
    margin: 20px 0;
    text-align: center;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 6px;
}

#save-results {
    background: #0073aa;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#save-results:hover:not(:disabled) {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#save-results:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#save-message {
    margin-top: 15px;
    min-height: 20px;
}

.success-message {
    background: #d1eddd;
    color: #155724;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #c3e6cb;
    display: inline-block;
    margin: 0 auto;
    animation: slideDown 0.3s ease-out;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
    display: inline-block;
    margin: 0 auto;
    animation: slideDown 0.3s ease-out;
}

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

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .toto-sfc-table {
        font-size: 14px;
    }
    
    .toto-sfc-table th,
    .toto-sfc-table td {
        padding: 8px 6px;
    }
    
    .fantasq-input {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    #toto-sfc-container {
        margin: 10px 0;
        padding: 0 10px;
    }
    
    .toto-sfc-table {
        font-size: 12px;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .toto-sfc-table thead,
    .toto-sfc-table tbody,
    .toto-sfc-table tr {
        display: table;
        table-layout: fixed;
        width: 100%;
    }
    
    .toto-sfc-table th,
    .toto-sfc-table td {
        padding: 8px 4px;
        min-width: 80px;
    }
    
    .toto-sfc-table th:first-child,
    .toto-sfc-table td:first-child {
        min-width: 150px;
    }
    
    .fantasq-input {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    
    .risultato-select {
        width: 50px;
        height: 30px;
        font-size: 12px;
    }
    
    .form-actions {
        padding: 15px;
        margin: 15px 0;
    }
    
    #save-results {
        padding: 10px 20px;
        font-size: 14px;
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .toto-sfc-table th,
    .toto-sfc-table td {
        padding: 6px 3px;
        min-width: 60px;
        font-size: 11px;
    }
    
    .toto-sfc-table th:first-child,
    .toto-sfc-table td:first-child {
        min-width: 120px;
    }
    
    .fantasq-input {
        width: 25px;
        height: 25px;
        font-size: 11px;
    }
    
    .risultato-select {
        width: 40px;
        height: 25px;
        font-size: 11px;
    }
    
    #toto-sfc-container h3 {
        font-size: 16px;
        padding: 8px 12px;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.hidden {
    display: none;
}

.visible {
    display: block;
}

/* ===== SCROLL BAR PERSONALIZZATA ===== */
.toto-sfc-table::-webkit-scrollbar {
    height: 8px;
}

.toto-sfc-table::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.toto-sfc-table::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.toto-sfc-table::-webkit-scrollbar-thumb:hover {
    background: #555;
}

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

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== ACCESSIBILITÀ ===== */
.toto-sfc-table:focus-within {
    box-shadow: 0 0 0 2px #0073aa;
}

.fantasq-input:focus,
.risultato-select:focus {
    z-index: 5;
    position: relative;
}

/* ===== STAMPA ===== */
@media print {
    #toto-sfc-container {
        color: black;
        background: white;
    }
    
    .toto-sfc-table {
        box-shadow: none;
        border: 1px solid black;
    }
    
    .toto-sfc-table th {
        background: #e9e9e9 !important;
        color: black !important;
    }
    
    .form-actions {
        display: none;
    }
    
    .fantasq-input,
    .risultato-select {
        border: 1px solid black;
        background: white;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    #toto-sfc-container {
        color: #e1e1e1;
    }
    
    .toto-sfc-table {
        background: #2c3338;
        color: #e1e1e1;
    }
    
    .toto-sfc-table tbody tr:nth-child(even) {
        background-color: #32373c;
    }
    
    .toto-sfc-table tbody tr:hover {
        background-color: #3c434a;
    }
    
    .toto-sfc-table td {
        border-color: #3c434a;
    }
    
    .fantasq-input,
    .risultato-select {
        background: #32373c;
        color: #e1e1e1;
        border-color: #3c434a;
    }
    
    .form-actions {
        background: #32373c;
    }
    
    .user-column {
        background-color: #3d2f2f;
    }
    
    .toto-sfc-table tbody tr:nth-child(even) .user-column {
        background-color: #432f2f;
    }
}