/*
 * Patente Nautica Calendar Plugin - Stili
 * Version: 2.0.0
 * Migrated from Weekly Calendar Plugin
 */

/* === CONTAINER PRINCIPALE === */
.weekly-calendar-container,
.patente-nautica-calendar {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fff !important;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
}

.weekly-calendar-container *,
.weekly-calendar-container *::before,
.weekly-calendar-container *::after,
.patente-nautica-calendar *,
.patente-nautica-calendar *::before,
.patente-nautica-calendar *::after {
    background-image: none !important;
    border-image: none !important;
    box-shadow: none !important;
}

.weekly-calendar-container .time-slot,
.weekly-calendar-container .hour-slot,
.patente-nautica-calendar .time-slot,
.patente-nautica-calendar .hour-slot {
    background: transparent !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
}

/* === CONTROLLI DEL CALENDARIO === */
.calendar-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.calendar-controls button {
    background: #4285f4;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.calendar-controls button:hover {
    background: #3367d6;
}

.btn-prev-week,
.btn-next-week {
    font-size: 18px;
    padding: 6px 10px;
}

.date-picker {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-left: auto;
}

/* === HEADER DEL CALENDARIO === */
.calendar-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333 !important;
    border-bottom: 1px solid #e0e0e0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    position: relative;
}

.current-week-range {
    color: #333 !important;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.calendar-version {
    position: absolute;
    right: 20px;
    font-size: 12px;
    font-weight: 400;
    color: #666;
    opacity: 0.7;
}

/* === GRIGLIA DEL CALENDARIO === */
.calendar-grid {
    display: flex;
    min-height: 600px;
    position: relative;
    background: none !important;
    background-image: none !important;
}

/* === COLONNA DEGLI ORARI === */
.time-column {
    width: 80px;
    border-right: 1px solid #e0e0e0;
    background: #fafafa;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.time-header {
    height: 60px;
    border-bottom: 1px solid #e0e0e0;
}

.time-slot {
    height: 40px;
    display: flex;
    justify-content: right;
    align-items: center;
    margin: 0;
    margin-right: 5px;
    padding: 0;
    font-size: 12px;
    color: #666;
    position: relative;
    box-sizing: border-box;
    line-height: 1;
    border-bottom: 1px solid #f0f0f0;
}

/* === CONTENITORE DEI GIORNI === */
.days-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: none !important;
    background-image: none !important;
}

.days-header {
    height: 60px;
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    z-index: 2;
    color: #333;
}

.day-header {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    border-right: 1px solid #e0e0e0;
    background: #f8f9fa;
}

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

.days-grid {
    display: flex;
    flex: 1;
    position: relative;
    background: none !important;
    background-image: none !important;
}

.day-column {
    flex: 1;
    border-right: 1px solid #e0e0e0;
    position: relative;
    display: flex;
    flex-direction: column;
}

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

.hour-slot {
    height: 40px;
    margin: 0;
    padding: 0;
    position: relative;
    cursor: pointer;
    box-sizing: border-box;
    line-height: 1;
    border-bottom: 1px solid #f0f0f0;
}

.hour-slot:hover {
    background: rgba(66, 133, 244, 0.1);
}

.current-day {
    background: rgba(66, 133, 244, 0.05);
}

/* === STILI DEGLI EVENTI === */
.event-box {
    position: absolute;
    color: white;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    z-index: 10;
    left: 2px;
    right: 2px;
}

.event-box:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    z-index: 20;
}

.event-box .event-title {
    font-weight: 600;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-box .event-time {
    font-size: 10px;
    opacity: 0.9;
    margin-top: 2px;
}

.event-box .event-status {
    font-size: 9px;
    opacity: 0.8;
    margin-top: 2px;
    text-transform: uppercase;
    font-weight: 700;
}

.event-box .event-instructor {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 9px;
    font-weight: 500;
    opacity: 0.9;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

/* === COLORI BASATI SULLO STATO === */
.event-box.status-programmata {
    background: #fbbc04;
    color: #333;
    border-color: #f9ab00;
}

.event-box.status-confermata {
    background: #34a853;
    color: white;
    border-color: #137333;
}

.event-box.status-cancellata {
    background: #ea4335;
    color: white;
    border-color: #d33b2c;
    opacity: 0.8;
    text-decoration: line-through;
}

/* === EVENTI PASSATI === */
.event-box.past-event {
    opacity: 0.4;
    filter: grayscale(50%);
    cursor: default;
}

.event-box.past-event:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* === TOOLTIP === */
.event-tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 12px;
    max-width: 320px;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    pointer-events: none;
    line-height: 1.4;
}

.event-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border: 6px solid transparent;
    border-top-color: #333;
}

.tooltip-title {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 13px;
}

.tooltip-time {
    font-size: 11px;
    opacity: 0.9;
    margin-bottom: 6px;
}

.tooltip-status {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 8px;
}

.tooltip-status.programmata {
    background: #fbbc04;
    color: #333;
}

.tooltip-status.confermata {
    background: #34a853;
    color: white;
}

.tooltip-status.cancellata {
    background: #ea4335;
    color: white;
}

.tooltip-description {
    font-size: 11px;
    opacity: 0.9;
    margin-bottom: 8px;
    border-bottom: 1px solid #555;
    padding-bottom: 8px;
}

.tooltip-participants {
    margin-top: 8px;
}

.tooltip-participants-title {
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    opacity: 0.8;
}

.participant-item {
    font-size: 11px;
    margin-bottom: 3px;
    padding: 2px 0;
}

.participant-name {
    font-weight: 500;
}

.participant-email {
    opacity: 0.7;
    font-size: 10px;
}

/* === MODAL POPUP === */
.event-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.event-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.event-modal-header {
    padding: 24px 24px 0 24px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
    flex: 1;
    line-height: 1.3;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    margin-left: 16px;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
}

.modal-close-btn:hover {
    color: #666;
}

.event-modal-body {
    padding: 0 24px;
    max-height: 50vh;
    overflow-y: auto;
}

.modal-section {
    margin-bottom: 24px;
}

.modal-label {
    font-weight: 600;
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-datetime {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-date {
    font-size: 18px;
    font-weight: 500;
    color: #333;
}

.modal-time {
    font-size: 16px;
    color: #666;
}

.modal-status {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-status.programmata {
    background: #fbbc04;
    color: #333;
}

.modal-status.confermata {
    background: #34a853;
    color: white;
}

.modal-status.cancellata {
    background: #ea4335;
    color: white;
}

.modal-description {
    font-size: 16px;
    line-height: 1.5;
    color: #444;
}

.modal-participants-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-participant {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.modal-participant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #4285f4;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.modal-participant-info {
    flex: 1;
}

.modal-participant-name {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    margin-bottom: 2px;
}

.modal-participant-email {
    font-size: 13px;
    color: #666;
}

.modal-participant-attendance {
    margin-left: 12px;
    flex-shrink: 0;
}

.attendance-icon {
    font-size: 23px;
    cursor: help;
    display: inline-block;
    transition: transform 0.2s ease;
}

.attendance-icon:hover {
    transform: scale(1.2);
}

.attendance-classroom {
    filter: hue-rotate(0deg);
}

.attendance-streaming {
    filter: hue-rotate(200deg);
}

.attendance-unknown {
    opacity: 0.6;
}

.event-modal-footer {
    padding: 20px 24px 24px 24px;
    border-top: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.modal-actions .subscribe-actions,
.modal-actions .change-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.modal-actions .change-actions .lesson-change-buttons-group {
    display: flex;
    flex-direction: row;
    gap: 10px;
    width: 100%;
}

.modal-actions .change-actions .lesson-change-buttons-group .btn-request-change {
    flex: 1;
    min-width: 0;
}

.modal-close-btn-footer {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.modal-close-btn-footer:hover {
    background: #5a6268;
}

/* === PULSANTI DI AZIONE === */
.btn-subscribe {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-subscribe:hover {
    background: #218838;
    transform: translateY(-1px);
}

.btn-subscribe:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.btn-unsubscribe {
    background: #dc3545;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-unsubscribe:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.btn-unsubscribe:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.btn-action-loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn-action-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.login-message {
    color: #6c757d;
    font-style: italic;
    font-size: 14px;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .calendar-controls {
        flex-wrap: wrap;
        gap: 8px;
    }

    .date-picker {
        margin-left: 0;
        flex: 1;
    }

    .time-column {
        width: 60px;
    }

    .time-slot {
        font-size: 10px;
        height: 40px;
    }

    .hour-slot {
        height: 40px;
    }

    .days-header {
        height: 50px;
    }

    .event-box {
        font-size: 10px;
        padding: 2px 4px;
    }

    .event-box .event-time {
        display: none;
    }

    .event-box .event-instructor {
        display: none;
    }

    .event-modal {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    .event-modal-header {
        padding: 16px 16px 0 16px;
    }

    .modal-title {
        font-size: 20px;
    }

    .event-modal-body {
        padding: 0 16px;
    }

    .event-modal-footer {
        padding: 16px;
        justify-content: space-between;
    }

    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }

    .attendance-buttons-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
}

/* Stili per i pulsanti di partecipazione */
.btn-subscribe-classroom,
.btn-subscribe-streaming {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    min-height: 44px;
    box-sizing: border-box;
}

.btn-subscribe-classroom {
    background: #007bff;
}

.btn-subscribe-streaming {
    background: #17a2b8;
}

.btn-subscribe-classroom:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.btn-subscribe-streaming:hover {
    background: #138496;
    transform: translateY(-1px);
}

.btn-subscribe-classroom:disabled,
.btn-subscribe-streaming:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.attendance-buttons-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

/* Stili responsivi per i pulsanti di partecipazione */
@media (min-width: 480px) {
    .attendance-buttons-group {
        flex-direction: row;
        gap: 12px;
    }

    .btn-subscribe-classroom,
    .btn-subscribe-streaming {
        flex: 1;
    }
}

/* Custom Alert Box Styles */
.custom-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    border: 1px solid #ccc;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 20000;
    max-width: 400px;
    width: 90%;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.custom-alert h2 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.custom-alert p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-line;
}

.custom-alert button {
    background-color: #4285f4;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.custom-alert button:hover {
    background-color: #3367d6;
}

/* Lesson Change Section Styles - Modal Body Version */
.lesson-change-modal-section {
    margin-bottom: 24px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.lesson-change-explanation {
    font-size: 13px;
    color: #666;
    margin-bottom: 16px;
    line-height: 1.4;
}

/* Legacy styles for footer version (kept for compatibility) */
.lesson-change-section {
    margin-top: 20px;
    padding: 16px 0;
}

.section-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 16px 0;
}

.lesson-change-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    text-align: center;
}

.lesson-change-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lesson-change-buttons {
    margin-top: 12px;
    width: 100%;
}

.lesson-change-buttons-group {
    display: flex;
    flex-direction: row;
    gap: 8px;
    width: 100%;
}

.lesson-change-buttons-group .btn-request-change {
    flex: 1;
}

.no-selection-message {
    padding: 12px;
    background: #f8f9fa;
    color: #666;
    text-align: center;
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.error-message {
    padding: 12px;
    background: #fff3cd;
    color: #856404;
    text-align: center;
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid #ffeaa7;
}

.modal-qualifications-section {
    margin-bottom: 24px;
}

.modal-qualifications {
    background: #e3f2fd;
    color: #0d47a1;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #bbdefb;
    font-weight: 600;
    font-size: 14px;
}

.lesson-change-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background-color: #fff;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s;
}

.lesson-change-select:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

.lesson-change-select:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.btn-request-change {
    background-color: #ff9800;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    width: 100%;
    box-sizing: border-box;
}

.btn-request-change:hover:not(:disabled) {
    background-color: #f57c00;
    transform: translateY(-1px);
}

.btn-request-change:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.btn-request-change.btn-action-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* === Toggle switch Iscrizione / Cambio Lezione === */
.modal-mode-toggle-container {
    width: 100%;
}

.modal-mode-toggle {
    display: flex;
    background: #e9ecef;
    border-radius: 25px;
    padding: 3px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
}

.modal-mode-toggle .toggle-option {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 22px;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    line-height: 1.3;
}

.modal-mode-toggle .toggle-option.active {
    background: #4285f4;
    color: white;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.modal-mode-toggle .toggle-option:hover:not(.active) {
    color: #333;
    background: rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .modal-mode-toggle .toggle-option {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* Responsive design for lesson change section */
@media (min-width: 480px) {
    .lesson-change-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .lesson-change-select {
        width: 100%;
        margin-right: 0;
    }

    .lesson-change-buttons {
        margin-top: 12px;
    }
}
