/* ========================================
   TRAININGS CALENDAR - Griglia Settimanale
   ======================================== */

.trainings-calendar-page {
    padding: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.calendar-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.calendar-header-bar h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #1f2937;
}

.btn-nav {
    padding: 0.5rem 1rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.btn-nav:hover {
    background: #2563eb;
}

/* Grid Container */
.calendar-grid-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    margin-bottom: 1rem;
}

.calendar-week-grid {
    min-width: 1200px;
}

/* Grid Header */
.grid-header {
    display: grid;
    grid-template-columns: 80px repeat(7, 1fr);
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
}

.time-column-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    font-weight: 600;
    color: #6b7280;
    border-right: 1px solid #e5e7eb;
}

.day-header {
    text-align: center;
    padding: 1rem 0.5rem;
    border-right: 1px solid #e5e7eb;
}

.day-header:last-child {
    border-right: none;
}

.day-header.today {
    background: #dbeafe;
}

.day-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 0.25rem;
}

.day-date {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Grid Body */
.grid-body {
    display: grid;
    grid-template-columns: 80px repeat(7, 1fr);
    position: relative;
}

.time-column {
    border-right: 1px solid #e5e7eb;
    background: #f9fafb;
    position: sticky;
    left: 0;
    z-index: 50;
}

.time-slot {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 0.25rem;
    font-size: 0.75rem;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 500;
}

.day-column {
    position: relative;
    border-right: 1px solid #e5e7eb;
}

.day-column:last-child {
    border-right: none;
}

.empty-slot {
    border-bottom: 1px solid #f3f4f6;
}

/* Training Blocks */
.training-block {
    position: absolute;
    left: 2px;
    right: 2px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer;
    overflow: hidden;
    font-size: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 10;
}

.training-block:hover {
    transform: translateX(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    z-index: 20;
}

.training-block.editable {
    border-left: 4px solid #fbbf24;
}

.training-time {
    font-weight: 700;
    margin-bottom: 0.25rem;
    font-size: 0.7rem;
}

.training-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.training-coaches {
    font-size: 0.65rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.training-participants {
    font-size: 0.65rem;
    opacity: 0.9;
}

/* Legend */
.calendar-legend {
    display: flex;
    gap: 2rem;
    justify-content: center;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 1rem;
}

.calendar-legend span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #1f2937;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.close-modal:hover {
    background: #f3f4f6;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

.form-group select[multiple] {
    padding: 0.5rem;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-primary:active,
.btn-secondary:active,
.btn-danger:active {
    transform: scale(0.98);
}

/* Body modal open */
body.modal-open {
    overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    .trainings-calendar-page {
        padding: 0.25rem;
    }

    .calendar-header-bar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .calendar-header-bar h2 {
        font-size: 1rem;
    }

    .btn-nav {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Griglia compatta mobile */
    .calendar-week-grid {
        min-width: 100%;
        font-size: 0.7rem;
    }

    .grid-header {
        grid-template-columns: 50px repeat(7, 1fr);
    }

    .time-column-header {
        padding: 0.5rem 0.25rem;
        font-size: 0.65rem;
    }

    .day-header {
        padding: 0.5rem 0.25rem;
    }

    .day-name {
        font-size: 0.65rem;
        margin-bottom: 0.125rem;
    }

    .day-date {
        font-size: 0.625rem;
    }

    .grid-body {
        grid-template-columns: 50px repeat(7, 1fr);
    }

    .time-slot {
        font-size: 0.6rem;
        padding-top: 0.125rem;
        height: 40px !important;
    }

    .empty-slot {
        height: 40px !important;
    }

    /* Training blocks più compatti */
    .training-block {
        font-size: 0.55rem;
        padding: 0.25rem;
        left: 1px;
        right: 1px;
        border-radius: 4px;
    }

    .training-time {
        font-size: 0.5rem;
        margin-bottom: 0.125rem;
    }

    .training-title {
        font-size: 0.55rem;
        margin-bottom: 0.125rem;
        -webkit-line-clamp: 1;
    }

    .training-coaches {
        font-size: 0.5rem;
        margin-bottom: 0.125rem;
    }

    .training-participants {
        font-size: 0.5rem;
    }

    /* Legenda più compatta */
    .calendar-legend {
        gap: 1rem;
        padding: 0.5rem;
        font-size: 0.75rem;
        margin-top: 0.5rem;
    }

    .legend-dot {
        width: 8px;
        height: 8px;
    }

    /* Form mobile */
    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-width: 95%;
        max-height: 85vh;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h3 {
        font-size: 1rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-group label {
        font-size: 0.8rem;
        margin-bottom: 0.375rem;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 0.625rem;
        font-size: 0.875rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }

    .form-actions button {
        width: 100%;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    /* Bottone aggiungi più piccolo */
    .btn-primary {
        font-size: 0.875rem;
        padding: 0.625rem 1rem;
    }
}

/* Mobile molto piccolo */
@media (max-width: 480px) {
    .calendar-header-bar h2 {
        font-size: 0.875rem;
    }

    .btn-nav {
        font-size: 0.75rem;
        padding: 0.5rem;
    }

    .grid-header {
        grid-template-columns: 40px repeat(7, 1fr);
    }

    .grid-body {
        grid-template-columns: 40px repeat(7, 1fr);
    }

    .time-column-header {
        font-size: 0.6rem;
        padding: 0.375rem 0.125rem;
    }

    .time-slot {
        font-size: 0.55rem;
        height: 35px !important;
    }

    .empty-slot {
        height: 35px !important;
    }

    .day-name {
        font-size: 0.6rem;
    }

    .day-date {
        font-size: 0.575rem;
    }

    .training-block {
        font-size: 0.5rem;
        padding: 0.2rem;
    }

    .training-time,
    .training-coaches,
    .training-participants {
        font-size: 0.475rem;
    }

    .training-title {
        font-size: 0.5rem;
    }

    .calendar-legend {
        font-size: 0.7rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Permetti zoom su mobile */
@media (max-width: 768px) {
    .calendar-grid-container {
        touch-action: pan-x pan-y pinch-zoom;
    }
}