/* ========================================
   RESPONSIVE STYLES - Calendrier Abrak
   VERSION CORRIGÉE POUR LES IMAGES
   ======================================== */

/* ========== TABLET (max-width: 1200px) ========== */
@media (max-width: 1200px) {
    .calendar-container {
        max-width: 100%;
    }

    .calendar-grid {
        gap: 10px;
    }

    .day-cell {
        min-height: 120px;
        padding: 10px;
    }

    .day-number {
        font-size: 1.2rem;
    }

    .event {
        font-size: 0.8rem;
        padding: 7px 9px;
    }

    .month-name {
        font-size: 2rem;
    }

    .nav-btn {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}

/* ========== MOBILE LANDSCAPE (max-width: 992px) ========== */
@media (max-width: 992px) {
    body {
        padding: var(--spacing-sm);
    }

    .calendar-header {
        padding: var(--spacing-md) var(--spacing-lg);
    }

    .month-name {
        font-size: 1.8rem;
    }

    .month-year {
        font-size: 1rem;
    }

    .calendar-body {
        padding: var(--spacing-md);
    }

    .day-cell {
        min-height: 110px;
    }

    .event-title {
        font-size: 0.75rem;
        -webkit-line-clamp: 1;
    }

    .add-btn {
        width: 60px;
        height: 60px;
        font-size: 2rem;
        bottom: var(--spacing-lg);
        right: var(--spacing-lg);
    }
}

/* ========== MOBILE (max-width: 768px) ========== */
@media (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
        align-items: flex-start;
        min-height: 100vh;
        height: 100%;
        overflow-x: hidden;
        touch-action: pan-y;
    }

    .calendar-container {
        border-radius: 0;
        margin: 0;
        border-width: 0;
        border-left: none;
        border-right: none;
        width: 100vw;
        min-height: 100vh;
        max-width: 100vw;
    }

    /* Header */
    .calendar-header {
        padding: 12px 16px;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .month-display {
        min-width: 0;
        flex: 1;
    }

    .month-name {
        font-size: 1.5rem;
        letter-spacing: 0.5px;
    }

    .month-year {
        font-size: 0.85rem;
        margin-top: 2px;
    }

    .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        flex-shrink: 0;
    }

    /* Calendar Grid */
    .calendar-body {
        padding: 8px;
        width: 100%;
        box-sizing: border-box;
    }

    .calendar-grid {
        gap: 3px;
        width: 100%;
    }

    .day-header {
        padding: 6px 2px;
        font-size: 0.65rem;
        letter-spacing: 0;
    }

    .day-cell {
        min-height: 85px;
        padding: 5px;
        border-radius: 6px;
        border-width: 2px;
    }

    .day-cell:hover {
        transform: translateY(-2px);
    }

    .day-number {
        font-size: 1rem;
        margin-bottom: 3px;
    }

    /* Events */
    .event {
        font-size: 0.65rem;
        padding: 4px 6px;
        margin-top: 3px;
        border-left-width: 3px;
        border-radius: 5px;
    }

    .event:hover {
        transform: translateX(2px);
    }

    .event-time {
        font-size: 0.6rem;
        gap: 2px;
    }

    .event-time::before {
        font-size: 0.75em;
    }

    .event-title {
        margin-top: 2px;
        font-size: 0.65rem;
        line-height: 1.2;
        -webkit-line-clamp: 2;
        word-break: break-word;
    }

    /* Add Button */
    .add-btn {
        width: 54px;
        height: 54px;
        font-size: 1.7rem;
        bottom: 18px;
        right: 18px;
        box-shadow: 0 4px 20px rgba(212, 175, 55, 0.5);
    }

    /* Panel Admin */
    #adminPanel {
        top: 12px;
        right: 12px;
        padding: 10px 16px;
        font-size: 0.85rem;
        gap: 10px;
    }

    #logoutBtn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    /* Toast notifications sur mobile */
    .toast {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        padding: 12px 16px;
        font-size: 0.85rem;
    }

    /* Empêcher le zoom sur les inputs */
    input, select, textarea {
        font-size: 16px !important;
        touch-action: manipulation;
    }

    /* Améliorer l'expérience tactile */
    button, a, .event, .day-cell {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Modal */
    .modal-content {
        width: 96%;
        max-width: none;
        border-radius: 12px;
        border-width: 2px;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-title {
        font-size: 1.15rem;
    }

    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 1.6rem;
    }

    .modal-body,
    #eventForm {
        padding: 20px;
    }

    .form-group {
        margin-bottom: 14px;
    }

    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 11px 13px;
        font-size: 0.95rem;
        border-radius: 8px;
    }

    .form-actions {
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
        padding-top: 16px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.95rem;
    }

    /* 🆕 Event details modal - IMAGES RESPONSIVES */
    .event-image-container {
        width: 100% !important;
        margin-bottom: 20px !important;
        border-radius: 10px !important;
        overflow: hidden !important;
        background: #fefaf3 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .event-image {
        width: 100% !important;
        height: auto !important;
        max-height: 300px !important;
        object-fit: contain !important;
        display: block !important;
        border: 2px solid #d4b373 !important;
        border-radius: 10px !important;
    }

    .event-main-info {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .event-main-title {
        font-size: 1.3rem;
        margin-bottom: 12px;
    }

    .event-meta {
        gap: 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .event-meta-item {
        font-size: 0.88rem;
        gap: 6px;
    }

    .event-meta-icon {
        font-size: 1.1em;
    }

    .event-meta-label {
        min-width: 50px;
    }

    .event-info-box {
        padding: 16px;
        margin: 16px 0;
        border-radius: 8px;
    }

    .event-description {
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .modal-actions {
        padding: 16px 20px;
        gap: 10px;
        flex-direction: column-reverse;
    }

    .btn-delete,
    .btn-edit,
    .btn-close-modal {
        width: 100%;
        padding: 12px 20px;
        font-size: 0.92rem;
    }
}

/* ========== SMALL MOBILE (max-width: 480px) ========== */
@media (max-width: 480px) {
    body {
        padding: 0;
        margin: 0;
        overflow-x: hidden;
    }

    .calendar-container {
        border: none;
        width: 100vw;
        max-width: 100vw;
        border-radius: 0;
        min-height: 100vh;
    }

    /* Header ultra compact */
    .calendar-header {
        padding: 10px 12px;
        gap: 6px;
    }

    .month-display {
        min-width: 0;
        flex: 1;
    }

    .month-name {
        font-size: 1.2rem;
        letter-spacing: 0;
    }

    .month-year {
        font-size: 0.75rem;
    }

    .nav-btn {
        width: 35px;
        height: 35px;
        font-size: 1rem;
        border-radius: 8px;
        padding: 0;
    }

    /* Calendar ultra compact */
    .calendar-body {
        padding: 6px;
        width: 100%;
        box-sizing: border-box;
    }

    .calendar-grid {
        gap: 2px;
        width: 100%;
    }

    .day-header {
        padding: 5px 0;
        font-size: 0.6rem;
        letter-spacing: 0;
    }

    .day-cell {
        min-height: 75px;
        padding: 4px;
        border-width: 1px;
        border-radius: 6px;
    }

    .day-cell:hover {
        transform: none;
    }

    .day-cell.today {
        border-width: 2px;
    }

    .day-number {
        font-size: 0.9rem;
        margin-bottom: 2px;
    }

    /* Events très compacts */
    .event {
        font-size: 0.6rem;
        padding: 3px 5px;
        margin-top: 2px;
        border-left-width: 2px;
        border-radius: 4px;
    }

    .event-time {
        font-size: 0.55rem;
        gap: 2px;
    }

    .event-time::before {
        display: none;
    }

    .event-title {
        font-size: 0.6rem;
        line-height: 1.15;
        -webkit-line-clamp: 1;
        word-break: break-word;
    }

    /* Add button compact */
    .add-btn {
        width: 50px;
        height: 50px;
        font-size: 1.6rem;
        bottom: 12px;
        right: 12px;
    }

    /* Modal mobile */
    .modal-content {
        padding: 15px;
        max-height: 95vh;
    }

    .modal-header {
        margin-bottom: 15px;
        padding-bottom: 12px;
    }

    .modal-title {
        font-size: 1.1rem;
    }

    .modal-close {
        width: 30px;
        height: 30px;
        font-size: 1.5rem;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 5px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px;
        font-size: 0.9rem;
    }

    .btn {
        padding: 10px;
        font-size: 0.85rem;
        letter-spacing: 0.3px;
    }

    /* 🆕 Images encore plus compactes sur petit mobile */
    .event-image-container {
        margin-bottom: 16px !important;
        border-radius: 8px !important;
    }

    .event-image {
        max-height: 250px !important;
        border-width: 2px !important;
        border-radius: 8px !important;
    }
}

/* ========== LANDSCAPE MOBILE ========== */
@media (max-width: 900px) and (orientation: landscape) {
    body {
        padding: 10px;
        align-items: flex-start;
    }

    .calendar-container {
        margin: 10px 0;
    }

    .calendar-header {
        padding: 15px 20px;
    }

    .month-name {
        font-size: 1.5rem;
    }

    .day-cell {
        min-height: 90px;
    }

    .add-btn {
        width: 50px;
        height: 50px;
        bottom: 15px;
        right: 15px;
    }

    /* 🆕 Images en mode paysage */
    .event-image-container {
        max-width: 80% !important;
        margin: 0 auto 20px auto !important;
    }

    .event-image {
        max-height: 350px !important;
    }
}

/* ========== PRINT STYLES ========== */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .calendar-container {
        box-shadow: none;
        border: 1px solid #333;
    }

    .calendar-header {
        background: #f0f0f0;
        border-bottom: 2px solid #333;
        color: #000;
    }

    .month-name,
    .month-year {
        color: #000;
    }

    .nav-btn,
    .add-btn {
        display: none;
    }

    .calendar-body {
        background: white;
    }

    .day-cell {
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    .event {
        background: #f9f9f9;
        border-left-width: 3px;
        page-break-inside: avoid;
    }

    .event-image {
        max-height: 300px;
        page-break-inside: avoid;
    }
}