/**
 * FGC Train Arrivals - Calendar Integration Styles
 * Styling for calendar export modal and buttons
 */

/* ============================================================================
   CALENDAR EXPORT BUTTON IN DEPARTURES TABLE
   ============================================================================ */

.calendar-export-btn {
    background: linear-gradient(135deg, #88BB0B 0%, #6A9308 100%);
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    box-shadow: 0 2px 8px rgba(136, 187, 11, 0.2);
    position: relative;
    overflow: hidden;
}

.calendar-export-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.calendar-export-btn:hover::before {
    width: 200px;
    height: 200px;
}

.calendar-export-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 16px rgba(136, 187, 11, 0.4);
}

.calendar-export-btn:active {
    transform: translateY(0) scale(0.98);
}

.calendar-export-btn:focus-visible {
    outline: 3px solid #88BB0B;
    outline-offset: 2px;
}

.calendar-export-btn .calendar-icon {
    font-size: 16px;
    line-height: 1;
    position: relative;
    z-index: 1;
}

/* Export Schedule Button in Header */
.export-schedule-btn {
    background: linear-gradient(135deg, #88BB0B 0%, #6A9308 100%);
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: white;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(136, 187, 11, 0.25);
    margin-right: 12px;
    min-width: 44px;
    min-height: 44px;
}

.export-schedule-btn .icon {
    font-size: 20px;
    line-height: 1;
}

.export-schedule-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(136, 187, 11, 0.35);
}

.export-schedule-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(136, 187, 11, 0.25);
}

.export-schedule-btn:focus-visible {
    outline: 3px solid #88BB0B;
    outline-offset: 2px;
}

/* ============================================================================
   CALENDAR MODAL
   ============================================================================ */

.calendar-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.calendar-modal-overlay.show {
    opacity: 1;
}

.calendar-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.calendar-modal-overlay.show .calendar-modal-content {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.calendar-modal-header {
    padding: 24px 24px 16px;
    border-bottom: 2px solid #E9ECEF;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-radius: 16px 16px 0 0;
}

.calendar-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #1A1A1A;
    margin: 0;
}

.calendar-modal-close {
    background: #F8F9FA;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    color: #6C757D;
    transition: all 0.2s ease;
    line-height: 1;
}

.calendar-modal-close:hover {
    background: #E9ECEF;
    color: #1A1A1A;
    transform: rotate(90deg);
}

.calendar-modal-close:focus-visible {
    outline: 3px solid #88BB0B;
    outline-offset: 2px;
}

/* Modal Body */
.calendar-modal-body {
    padding: 24px;
}

.calendar-modal-subtitle {
    font-size: 14px;
    color: #6C757D;
    margin: 0 0 24px;
}

/* ============================================================================
   EVENT PREVIEW
   ============================================================================ */

.calendar-event-preview {
    background: linear-gradient(135deg, #F8F9FA 0%, #E9ECEF 100%);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    border: 2px solid #E9ECEF;
}

.calendar-preview-title {
    font-size: 14px;
    font-weight: 700;
    color: #88BB0B;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 16px;
}

.calendar-preview-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.calendar-preview-item:last-child {
    margin-bottom: 0;
}

.calendar-preview-label {
    font-size: 13px;
    font-weight: 600;
    color: #6C757D;
    flex-shrink: 0;
}

.calendar-preview-value {
    font-size: 14px;
    color: #1A1A1A;
    text-align: right;
    font-weight: 500;
}

/* ============================================================================
   CALENDAR OPTIONS
   ============================================================================ */

.calendar-options {
    margin-bottom: 24px;
}

.calendar-option-group {
    margin-bottom: 20px;
}

.calendar-option-group:last-child {
    margin-bottom: 0;
}

.calendar-option-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1A1A1A;
    margin-bottom: 8px;
}

/* Select Dropdown */
.calendar-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E9ECEF;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Montserrat', sans-serif;
    color: #1A1A1A;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calendar-select:hover {
    border-color: #88BB0B;
}

.calendar-select:focus {
    outline: none;
    border-color: #88BB0B;
    box-shadow: 0 0 0 3px rgba(136, 187, 11, 0.1);
}

/* Checkbox */
.calendar-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #1A1A1A;
    padding: 12px 0;
}

.calendar-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #88BB0B;
}

/* Recurring Options */
.calendar-recurring-options {
    background: #F8F9FA;
    border-radius: 10px;
    padding: 20px;
    margin-top: 16px;
    border: 2px solid #E9ECEF;
}

/* Weekday Selector */
.calendar-weekday-selector {
    margin-bottom: 20px;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.calendar-weekday {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 10px 6px;
    border: 2px solid #E9ECEF;
    border-radius: 8px;
    background: white;
    transition: all 0.2s ease;
    font-size: 12px;
    font-weight: 600;
}

.calendar-weekday input[type="checkbox"] {
    display: none;
}

.calendar-weekday:hover {
    border-color: #88BB0B;
    background: #F8FFF0;
}

.calendar-weekday input:checked + span {
    color: white;
}

.calendar-weekday:has(input:checked) {
    background: linear-gradient(135deg, #88BB0B 0%, #6A9308 100%);
    border-color: #88BB0B;
    color: white;
}

.calendar-weekday span {
    color: #1A1A1A;
    font-weight: 600;
    transition: color 0.2s ease;
}

/* Date Range */
.calendar-date-range {
    display: grid;
    gap: 16px;
}

.calendar-date-input label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1A1A1A;
    margin-bottom: 8px;
}

.calendar-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #E9ECEF;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Montserrat', sans-serif;
    color: #1A1A1A;
    background: white;
    transition: all 0.2s ease;
}

.calendar-input:hover {
    border-color: #88BB0B;
}

.calendar-input:focus {
    outline: none;
    border-color: #88BB0B;
    box-shadow: 0 0 0 3px rgba(136, 187, 11, 0.1);
}

/* ============================================================================
   CALENDAR TYPE BUTTONS
   ============================================================================ */

.calendar-type-buttons {
    display: grid;
    gap: 12px;
}

.calendar-type-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border: 2px solid #E9ECEF;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.calendar-type-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(136, 187, 11, 0.1), transparent);
    transition: left 0.5s ease;
}

.calendar-type-btn:hover::before {
    left: 100%;
}

.calendar-type-btn:hover {
    border-color: #88BB0B;
    background: #F8FFF0;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(136, 187, 11, 0.15);
}

.calendar-type-btn:active {
    transform: translateX(2px) scale(0.98);
}

.calendar-type-btn:focus-visible {
    outline: 3px solid #88BB0B;
    outline-offset: 2px;
}

.calendar-btn-icon {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
}

.calendar-btn-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.calendar-btn-label {
    font-size: 16px;
    font-weight: 700;
    color: #1A1A1A;
}

.calendar-btn-desc {
    font-size: 13px;
    color: #6C757D;
}

/* Specific button colors */
.calendar-btn-google:hover {
    border-color: #4285F4;
}

.calendar-btn-google:hover .calendar-btn-label {
    color: #4285F4;
}

.calendar-btn-outlook:hover {
    border-color: #0078D4;
}

.calendar-btn-outlook:hover .calendar-btn-label {
    color: #0078D4;
}

.calendar-btn-ics:hover {
    border-color: #88BB0B;
}

.calendar-btn-ics:hover .calendar-btn-label {
    color: #88BB0B;
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

.calendar-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1A1A1A;
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90vw;
}

.calendar-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.calendar-toast-success {
    background: linear-gradient(135deg, #88BB0B 0%, #6A9308 100%);
}

.calendar-toast-error {
    background: linear-gradient(135deg, #DC3545 0%, #C82333 100%);
}

/* ============================================================================
   DARK MODE SUPPORT
   ============================================================================ */

body.dark-mode .calendar-modal-content {
    background: #1E1E1E;
}

body.dark-mode .calendar-modal-header {
    background: #1E1E1E;
    border-bottom-color: #333;
}

body.dark-mode .calendar-modal-title {
    color: #F8F9FA;
}

body.dark-mode .calendar-modal-close {
    background: #2A2A2A;
    color: #ADB5BD;
}

body.dark-mode .calendar-modal-close:hover {
    background: #333;
    color: #F8F9FA;
}

body.dark-mode .calendar-modal-subtitle {
    color: #ADB5BD;
}

body.dark-mode .calendar-event-preview {
    background: linear-gradient(135deg, #2A2A2A 0%, #252525 100%);
    border-color: #333;
}

body.dark-mode .calendar-preview-label {
    color: #ADB5BD;
}

body.dark-mode .calendar-preview-value {
    color: #F8F9FA;
}

body.dark-mode .calendar-option-label {
    color: #F8F9FA;
}

body.dark-mode .calendar-select,
body.dark-mode .calendar-input {
    background: #2A2A2A;
    border-color: #333;
    color: #F8F9FA;
}

body.dark-mode .calendar-select:hover,
body.dark-mode .calendar-input:hover {
    border-color: #88BB0B;
}

body.dark-mode .calendar-checkbox-label {
    color: #F8F9FA;
}

body.dark-mode .calendar-recurring-options {
    background: #2A2A2A;
    border-color: #333;
}

body.dark-mode .calendar-weekday {
    background: #252525;
    border-color: #333;
    color: #F8F9FA;
}

body.dark-mode .calendar-weekday span {
    color: #F8F9FA;
}

body.dark-mode .calendar-weekday:hover {
    background: #2A2A2A;
}

body.dark-mode .calendar-type-btn {
    background: #2A2A2A;
    border-color: #333;
}

body.dark-mode .calendar-type-btn:hover {
    background: #252525;
    border-color: #88BB0B;
}

body.dark-mode .calendar-btn-label {
    color: #F8F9FA;
}

body.dark-mode .calendar-btn-desc {
    color: #ADB5BD;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    .calendar-modal-content {
        max-width: 100%;
        max-height: 95vh;
        margin: 10px;
    }

    .calendar-modal-header {
        padding: 20px 16px 12px;
    }

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

    .calendar-modal-body {
        padding: 16px;
    }

    .calendar-weekdays {
        gap: 6px;
    }

    .calendar-weekday {
        padding: 8px 4px;
        font-size: 11px;
    }

    .calendar-type-btn {
        padding: 14px 16px;
        gap: 12px;
    }

    .calendar-btn-icon {
        font-size: 28px;
    }

    .calendar-btn-label {
        font-size: 15px;
    }

    .calendar-btn-desc {
        font-size: 12px;
    }

    /* Smaller calendar button in table on mobile */
    .calendar-export-btn {
        padding: 5px 8px;
        margin-left: 4px;
    }

    .calendar-export-btn .calendar-icon {
        font-size: 14px;
    }

    /* Header export button */
    .export-schedule-btn {
        padding: 8px 12px;
        font-size: 13px;
        margin-right: 8px;
    }

    .export-schedule-btn .icon {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .calendar-event-preview {
        padding: 16px;
    }

    .calendar-preview-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .calendar-preview-value {
        text-align: left;
    }

    .calendar-weekdays {
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
    }

    .calendar-weekday {
        padding: 6px 2px;
        font-size: 10px;
    }

    .calendar-date-range {
        grid-template-columns: 1fr;
    }

    .calendar-toast {
        bottom: 16px;
        padding: 12px 20px;
        font-size: 13px;
    }
}

/* ============================================================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================================================ */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .calendar-modal-content {
        border: 3px solid currentColor;
    }

    .calendar-type-btn {
        border-width: 3px;
    }

    .calendar-weekday {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .calendar-modal-overlay,
    .calendar-modal-content,
    .calendar-type-btn,
    .calendar-export-btn,
    .export-schedule-btn,
    .calendar-toast,
    .calendar-weekday {
        transition: none;
    }

    .calendar-type-btn::before {
        display: none;
    }

    .calendar-export-btn::before {
        display: none;
    }
}

/* Focus visible styles for keyboard navigation */
.calendar-weekday:focus-within {
    outline: 3px solid #88BB0B;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .calendar-modal-overlay,
    .calendar-export-btn,
    .export-schedule-btn {
        display: none;
    }
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.calendar-type-btn.loading {
    pointer-events: none;
    opacity: 0.6;
}

.calendar-type-btn.loading::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 3px solid #E9ECEF;
    border-top-color: #88BB0B;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* ============================================================================
   ANIMATION CLASSES
   ============================================================================ */

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.calendar-type-btn {
    animation: slideInUp 0.3s ease backwards;
}

.calendar-type-btn:nth-child(1) {
    animation-delay: 0.05s;
}

.calendar-type-btn:nth-child(2) {
    animation-delay: 0.1s;
}

.calendar-type-btn:nth-child(3) {
    animation-delay: 0.15s;
}
