/**
 * Modal CSS - Unified modal/overlay system
 * Used across admin, calendar, and my-calendars pages
 */

/* ============================================
   Base Overlay (full-screen backdrop)
   ============================================ */
.modal-overlay,
.export-modal-overlay,
.event-details-overlay,
.delete-modal,
.modal,
.event-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

/* Active/show states */
.modal-overlay.active,
.export-modal-overlay.active,
.event-details-overlay.active,
.delete-modal.show,
.modal.show,
.event-modal.active {
    display: flex;
}

/* ============================================
   Modal Panel (content container)
   ============================================ */
.modal-content {
    background: white;
    border-radius: 8px;
    padding: 20px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

/* Size variants */
.modal-content-sm {
    max-width: 400px;
}

.export-modal-wide {
    max-width: 520px;
}

/* Admin modals with dropdown pickers need extra breathing room */
.admin-modal .modal-content {
    padding-bottom: 40px;
    max-height: 85vh;
}

.delete-modal-content {
    max-width: 400px;
    text-align: center;
}

/* ============================================
   Modal Header
   ============================================ */
.modal-header,
.event-modal-header {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    /* padding-top: 10px; */
    padding-bottom: 15px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.event-modal-header {
    font-size: 24px;
    justify-content: flex-start;
}

.modal-header h2 {
    font-size: 20px;
    color: #2c3e50;
    margin: 0;
}

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

/* Delete modal headings (no border, centered) */
.delete-modal-content h2,
.delete-modal-content h3 {
    font-size: 20px;
    color: #2c3e50;
    margin-bottom: 15px;
}

.delete-modal-content p {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
    line-height: 1.5;
}

/* ============================================
   Modal Close Button
   ============================================ */
.close-modal {
    font-family: 'BMWTypeNext-Regular', sans-serif;
    font-weight: normal;
    position: absolute;
    top: 0px;
    right: 15px;
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    color: #333333;
    padding: 0;
    width: auto;
    max-width: none;
}

.close-modal:hover {
    color: #333;
    background: none;
}

.event-modal-header .close-modal, .modal-header .close-modal {
    position: relative;
    right: 0;
    padding: 0;
    margin: 0;
    /* margin-left: auto; */
}

.event-modal .btn-save, .event-modal .btn-create, .event-modal .btn-delete {
    width: auto;
    min-width: 80px;
}

.event-modal .btn-save, .event-modal .btn-create {
    margin-left: auto;
}

/* ============================================
   Modal Footer / Buttons
   ============================================ */
.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.modal-buttons button {
    flex: 1;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    width: auto;
    max-width: none;
}

/* ============================================
   Event Details Panel (read-only modal)
   ============================================ */
/* ============================================
   Requester Info Block (Event Page Request)
   ============================================ */
.requester-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.requester-info-row {
    display: flex;
    gap: 8px;
    font-size: 14px;
    margin-bottom: 4px;
}

.requester-label {
    font-weight: 600;
    color: #555;
}

.requester-info-note {
    font-size: 12px;
    color: #888;
    margin: 8px 0 0;
}

.event-details-department {
    color: var(--color-primary);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 3px;
}

.event-details-section {
    color: #888;
    font-size: 11px;
    margin-bottom: 10px;
}

.event-details-title {
    font-size: 20px;
    margin-bottom: 10px;
    color: #2c3e50;
    font-weight: 600;
}

.event-details-grid {
    border-top: 1px solid #eee;
    padding-top: 15px;
    margin-bottom: 15px;
}

.event-details-grid dl {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    font-size: 13px;
}

.event-details-grid dt {
    color: #666;
    font-weight: 600;
}

.event-details-grid dd {
    color: #333;
    margin: 0;
}

.event-details-description {
    margin-bottom: 20px;
    overflow: auto;
}

.event-details-description h4 {
    color: #666;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.event-details-description p {
    color: #666;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

/* ============================================
   Event History Section
   ============================================ */
.event-history-section {
    margin-top: 16px;
    margin-bottom: 20px;
    border-top: 1px solid #eee;
    padding-top: 12px;
}

.event-history-toggle {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
    padding: 6px 10px;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    background: #f0f4ff;
    transition: background 0.2s, color 0.2s;
}

.event-history-toggle::before {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.2s;
}

.event-history-toggle.open::before,
details[open] > .event-history-toggle::before {
    transform: rotate(45deg);
}

.event-history-toggle:hover {
    background: #e0eaff;
    color: var(--color-primary);
}

.event-history-toggle::-webkit-details-marker,
.event-history-toggle::marker {
    display: none;
    content: '';
}

.event-history-list {
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.history-entry {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 12px;
}

.history-entry:last-child {
    border-bottom: none;
}

.history-action {
    font-weight: 600;
    text-transform: capitalize;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.history-action.created {
    background: #d4edda;
    color: #155724;
}

.history-action.updated {
    background: #fff3cd;
    color: #856404;
}

.history-action.deleted {
    background: #f8d7da;
    color: #721c24;
}

.history-performer {
    color: #555;
}

.history-date {
    color: #999;
    margin-left: auto;
    white-space: nowrap;
}

.history-empty,
.loading-text {
    color: #999;
    font-size: 12px;
    font-style: italic;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {

    .modal-content,
    .export-modal-wide,
    .delete-modal-content {
        width: 95%;
        padding: 20px;
        padding-top: 10px;
    }

    /* Stack event date/time form row */
    .event-modal .form-row.flex-row {
        flex-direction: column;
        align-items: stretch;
    }

    .event-modal .form-row.flex-row .form-group {
        width: 100%;
    }

    .modal-buttons {
        flex-direction: column;
    }

    .modal-buttons button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .event-details-grid dl {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .event-details-grid dt {
        margin-top: 8px;
    }

    .modal-content {
        padding: 15px;
        max-height: 90vh;
    }

    .modal-header,
    .event-modal-header {
        font-size: 18px;
        padding-bottom: 10px;
        margin-bottom: 15px;
    }
}

/* ============================================
   Recurrence UI
   ============================================ */
.recurrence-end-group {
    display: none;
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.recurrence-end-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

.recurrence-end-group label input[type="checkbox"] {
    margin: 0;
}

.recurrence-hint {
    font-size: 0.82rem;
    color: #6c757d;
    font-style: italic;
    margin-top: 6px;
    min-height: 1.2em;
}

/* Recurrence choice modal (this or all) */
.recurrence-choice-content {
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.recurrence-choice-content h3 {
    margin: 0 0 12px;
    font-size: 1.1rem;
}

.recurrence-choice-content p {
    margin: 0 0 20px;
    color: #555;
    font-size: 0.95rem;
}

.recurrence-choice-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.recurrence-choice-buttons .btn {
    min-width: 130px;
}
