/**
 * SP Event Calendar - Frontend Styles
 * Clean design with role-based permissions
 */

/* ============================================
   MODAL STYLES
   ============================================ */

#sp-event-modal.sp-modal,
#sp-add-event-modal.sp-modal,
#sp-edit-event-modal.sp-modal,
div.sp-modal {
    display: none;
    position: fixed !important;
    z-index: 999999 !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: auto !important;
    background-color: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    padding: 20px !important;
    box-sizing: border-box !important;
}

div.sp-modal .sp-modal-content {
    position: relative !important;
    background-color: #ffffff !important;
    margin: 30px auto !important;
    padding: 0 !important;
    border-radius: 12px !important;
    width: 100% !important;
    max-width: 440px !important;
    max-height: calc(100vh - 80px) !important;
    overflow: hidden !important;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35) !important;
    animation: spModalSlideIn 0.25s ease-out !important;
    border: none !important;
}

@keyframes spModalSlideIn {
    from { opacity: 0; transform: translateY(-30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Close Button */
div.sp-modal .sp-modal-close {
    position: absolute !important;
    right: 12px !important;
    top: 12px !important;
    color: #718096 !important;
    font-size: 24px !important;
    font-weight: 300 !important;
    cursor: pointer !important;
    z-index: 100 !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    line-height: 1 !important;
    padding: 0 !important;
    transition: all 0.2s ease !important;
}

div.sp-modal .sp-modal-close:hover {
    background: #fed7d7 !important;
    color: #e53e3e !important;
    border-color: #fc8181 !important;
}

/* Modal Header */
div.sp-modal .sp-modal-header {
    padding: 16px 20px !important;
    padding-right: 50px !important;
    border-bottom: 1px solid #e2e8f0 !important;
    background: #e8f4f8 !important;
}

div.sp-modal .sp-modal-header h2 {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #0292B7 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: transparent !important;
    border: none !important;
}

div.sp-modal .sp-modal-header h2 .dashicons {
    font-size: 18px !important;
    width: 18px !important;
    height: 18px !important;
}

/* Modal Body */
div.sp-modal .sp-modal-body {
    padding: 20px 24px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: calc(100vh - 180px) !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
}

div.sp-modal .sp-modal-body .sp-form-row {
    background: transparent !important;
}

div.sp-modal .sp-modal-body input[type="text"],
div.sp-modal .sp-modal-body input[type="url"],
div.sp-modal .sp-modal-body input[type="number"],
div.sp-modal .sp-modal-body input[type="datetime-local"],
div.sp-modal .sp-modal-body textarea,
div.sp-modal .sp-modal-body select {
    background: #ffffff !important;
}

#sp-modal-body {
    padding: 0 !important;
    background: #ffffff !important;
}

/* ============================================
   FORM STYLES
   ============================================ */

div.sp-modal .sp-form-row {
    margin-bottom: 14px !important;
}

div.sp-modal .sp-form-row label {
    display: block !important;
    margin-bottom: 5px !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    color: #2d3748 !important;
}

div.sp-modal .sp-form-row input[type="text"],
div.sp-modal .sp-form-row input[type="email"],
div.sp-modal .sp-form-row input[type="url"],
div.sp-modal .sp-form-row input[type="number"],
div.sp-modal .sp-form-row input[type="datetime-local"],
div.sp-modal .sp-form-row textarea {
    width: 100% !important;
    padding: 10px 12px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    background: #ffffff !important;
    color: #2d3748 !important;
    box-sizing: border-box !important;
    transition: all 0.2s ease !important;
}

div.sp-modal .sp-form-row input:focus,
div.sp-modal .sp-form-row textarea:focus {
    outline: none !important;
    border-color: #0292B7 !important;
    box-shadow: 0 0 0 3px rgba(2, 146, 183, 0.15) !important;
}

div.sp-modal .sp-form-row textarea {
    resize: vertical !important;
    min-height: 70px !important;
}

/* Vertical date fields */
div.sp-modal .sp-form-row-half {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
}

div.sp-modal .sp-form-row-half > div {
    width: 100% !important;
}

/* Horizontal for capacity/color */
div.sp-modal .sp-form-row-inline {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
}

div.sp-modal .sp-form-row input[type="color"] {
    width: 50px !important;
    height: 36px !important;
    padding: 3px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    cursor: pointer !important;
}

/* Form Actions */
div.sp-modal .sp-form-actions {
    display: flex !important;
    gap: 10px !important;
    margin-top: 20px !important;
    padding-top: 20px !important;
    border-top: 1px solid #e2e8f0 !important;
    flex-wrap: wrap !important;
    background: #ffffff !important;
}

/* Primary Button */
div.sp-modal .sp-btn-primary {
    flex: 1 !important;
    min-width: 120px !important;
    padding: 10px 16px !important;
    border-radius: 8px !important;
    border: none !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    background: #48bb78 !important;
    color: #ffffff !important;
    transition: all 0.2s ease !important;
}

div.sp-modal .sp-btn-primary:hover {
    background: #38a169 !important;
    transform: translateY(-1px) !important;
}

/* Secondary Button */
div.sp-modal .sp-btn-secondary,
div.sp-modal .sp-modal-cancel {
    flex: 0 0 auto !important;
    padding: 10px 16px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #f7fafc !important;
    color: #718096 !important;
    border: 1px solid #e2e8f0 !important;
    transition: all 0.2s ease !important;
}

div.sp-modal .sp-btn-secondary:hover,
div.sp-modal .sp-modal-cancel:hover {
    background: #edf2f7 !important;
    color: #2d3748 !important;
}

/* Danger Button */
div.sp-modal .sp-btn-danger {
    flex: 0 0 auto !important;
    padding: 10px 12px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #fed7d7 !important;
    color: #c53030 !important;
    border: 1px solid #fc8181 !important;
    transition: all 0.2s ease !important;
}

div.sp-modal .sp-btn-danger:hover {
    background: #e53e3e !important;
    color: #ffffff !important;
}

div.sp-modal .sp-form-actions-edit {
    justify-content: space-between !important;
}

/* ============================================
   IMAGE UPLOAD IN EDIT MODAL
   ============================================ */

div.sp-modal .sp-image-upload-wrapper {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
}

div.sp-modal .sp-image-preview-container {
    position: relative !important;
    display: none !important;
    max-width: 150px !important;
}

div.sp-modal .sp-image-preview-container.has-image {
    display: inline-block !important;
}

div.sp-modal .sp-image-preview-container img {
    max-width: 150px !important;
    max-height: 100px !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    display: block !important;
}

div.sp-modal .sp-btn-remove-img {
    position: absolute !important;
    top: -8px !important;
    right: -8px !important;
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    background: #e53e3e !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
}

div.sp-modal .sp-btn-remove-img .dashicons {
    font-size: 14px !important;
    width: 14px !important;
    height: 14px !important;
}

div.sp-modal .sp-btn-upload {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 14px !important;
    background: #e8f4f8 !important;
    color: #0292B7 !important;
    border: 1px solid #0292B7 !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    width: fit-content !important;
}

div.sp-modal .sp-btn-upload:hover {
    background: #0292B7 !important;
    color: #ffffff !important;
}

/* ============================================
   EVENT DETAILS
   ============================================ */

.sp-event-details {
    padding: 20px !important;
    background: #ffffff !important;
}

.sp-event-header {
    margin-bottom: 16px !important;
    padding-bottom: 16px !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

.sp-event-title {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #0292B7 !important;
    margin: 0 0 8px 0 !important;
}

.sp-event-date-time {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 13px !important;
    color: #718096 !important;
    font-weight: 500 !important;
}

.sp-event-date-time .dashicons {
    color: #0292B7 !important;
    font-size: 16px !important;
    width: 16px !important;
    height: 16px !important;
}

/* Image Section */
.sp-event-image-section {
    margin-bottom: 16px !important;
}

.sp-event-image {
    border-radius: 8px !important;
    overflow: hidden !important;
    margin-bottom: 8px !important;
}

.sp-event-image img {
    width: 100% !important;
    height: auto !important;
    display: block !important;
    max-height: 180px !important;
    object-fit: cover !important;
}

/* Add Image Placeholder */
.sp-add-image-placeholder {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 30px 20px !important;
    background: #f7fafc !important;
    border: 2px dashed #cbd5e0 !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    color: #718096 !important;
}

.sp-add-image-placeholder:hover {
    background: #e8f4f8 !important;
    border-color: #0292B7 !important;
    color: #0292B7 !important;
}

.sp-add-image-placeholder .dashicons {
    font-size: 32px !important;
    width: 32px !important;
    height: 32px !important;
    margin-bottom: 8px !important;
}

.sp-add-image-placeholder span:last-child {
    font-size: 13px !important;
    font-weight: 600 !important;
}

.sp-btn-change-image {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 6px 12px !important;
    background: #e8f4f8 !important;
    color: #0292B7 !important;
    border: 1px solid #0292B7 !important;
    border-radius: 6px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.sp-btn-change-image:hover {
    background: #0292B7 !important;
    color: #ffffff !important;
}

.sp-btn-change-image .dashicons {
    font-size: 14px !important;
    width: 14px !important;
    height: 14px !important;
}

.sp-event-description {
    font-size: 13px !important;
    line-height: 1.6 !important;
    color: #4a5568 !important;
    margin-bottom: 16px !important;
    background: #f7fafc !important;
    padding: 12px !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
}

/* Info Grid */
.sp-event-info-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
}

.sp-event-info-item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    background: #f7fafc !important;
}

.sp-event-info-item.meeting-item {
    background: #e8f4f8 !important;
    border-color: #b2e0eb !important;
}

.sp-event-info-item.participants-item {
    background: #c6f6d5 !important;
    border-color: #9ae6b4 !important;
}

.sp-event-info-item.location-item {
    background: #fae8ff !important;
    border-color: #e9d5ff !important;
}

.sp-event-info-item.organizer-item {
    background: #fef3c7 !important;
    border-color: #fcd34d !important;
}

.sp-event-info-item .dashicons {
    color: #718096 !important;
    font-size: 18px !important;
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0 !important;
}

.sp-event-info-content {
    flex: 1 !important;
    min-width: 0 !important;
}

.sp-event-info-label {
    font-size: 9px !important;
    color: #718096 !important;
    text-transform: uppercase !important;
    font-weight: 700 !important;
    margin-bottom: 2px !important;
    letter-spacing: 0.5px !important;
}

.sp-event-info-value {
    font-size: 12px !important;
    color: #2d3748 !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.sp-event-info-value a {
    color: #0292B7 !important;
    text-decoration: none !important;
}

.sp-event-info-value a:hover {
    text-decoration: underline !important;
}

/* Event Actions */
.sp-event-actions {
    display: flex !important;
    gap: 8px !important;
    padding-top: 16px !important;
    border-top: 1px solid #e2e8f0 !important;
    flex-wrap: wrap !important;
}

.sp-event-registered {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 10px 14px !important;
    background: #c6f6d5 !important;
    color: #276749 !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    flex: 1 !important;
}

.sp-no-permission {
    flex: 1 !important;
    padding: 10px 14px !important;
    background: #fed7d7 !important;
    color: #c53030 !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    text-align: center !important;
}

.sp-btn-join-event {
    flex: 1 !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
    border: none !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    background: #48bb78 !important;
    color: #ffffff !important;
    transition: all 0.2s ease !important;
}

.sp-btn-join-event:hover {
    background: #38a169 !important;
}

.sp-btn-unregister {
    padding: 10px 14px !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    background: #fed7d7 !important;
    color: #c53030 !important;
    border: 1px solid #fc8181 !important;
    transition: all 0.2s ease !important;
}

.sp-btn-unregister:hover {
    background: #e53e3e !important;
    color: #ffffff !important;
}

.sp-btn-edit-event {
    padding: 10px 14px !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    background: #e8f4f8 !important;
    color: #0292B7 !important;
    border: 1px solid #0292B7 !important;
    transition: all 0.2s ease !important;
}

.sp-btn-edit-event:hover {
    background: #0292B7 !important;
    color: #ffffff !important;
}

/* ============================================
   CALENDAR WRAPPER
   ============================================ */

.sp-event-calendar-wrapper {
    font-family: 'Raleway', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    max-width: 100%;
    margin: 15px 0;
    background: #ffffff;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    font-size: 13px;
    color: #2d3748;
}

.sp-event-calendar-wrapper * {
    box-sizing: border-box;
}

.sp-calendar-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.sp-btn-add-event {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #c6f6d5;
    color: #276749;
    border: 1px solid #48bb78;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sp-btn-add-event:hover {
    background: #48bb78;
    color: #ffffff;
}

.sp-btn-add-event .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* FullCalendar */
.sp-event-calendar {
    background: #f7fafc;
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #e2e8f0;
}

.sp-event-calendar .fc-toolbar-title {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
}

.sp-event-calendar .fc-button {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #2d3748;
    font-weight: 500;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sp-event-calendar .fc-button:hover {
    background: #e8f4f8;
    border-color: #0292B7;
    color: #0292B7;
}

.sp-event-calendar .fc-button-active {
    background: #e8f4f8 !important;
    border-color: #0292B7 !important;
    color: #0292B7 !important;
}

.sp-event-calendar .fc-daygrid-day:hover {
    background: #fef3c7;
    cursor: pointer;
}

.sp-event-calendar .fc-daygrid-day-today {
    background: #fef3c7 !important;
}

.sp-event-calendar .fc-event {
    border-radius: 4px;
    padding: 2px 6px;
    font-weight: 500;
    font-size: 11px;
    border: none;
    cursor: pointer;
}

/* ============================================
   UTILITIES
   ============================================ */

/* WordPress Media Modal - ensure it's above everything */
.media-modal-backdrop {
    z-index: 1000050 !important;
}

.media-modal {
    z-index: 1000060 !important;
}

.sp-loading {
    text-align: center;
    padding: 40px 20px;
    color: #718096;
}

.sp-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top-color: #0292B7;
    border-radius: 50%;
    animation: spCalSpin 0.7s linear infinite;
    margin: 0 auto 10px;
}

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

.sp-error {
    text-align: center;
    padding: 20px;
    color: #c53030;
    background: #fed7d7;
    border-radius: 8px;
    font-size: 13px;
    margin: 20px;
}

.sp-no-events {
    text-align: center;
    padding: 30px;
    color: #718096;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px dashed #e2e8f0;
}

/* ============================================
   MOBILE
   ============================================ */

@media (max-width: 768px) {
    div.sp-modal .sp-modal-content {
        width: 95% !important;
        margin: 15px auto !important;
        max-height: calc(100vh - 30px) !important;
    }
    
    .sp-event-info-grid {
        grid-template-columns: 1fr !important;
    }
    
    .sp-event-actions {
        flex-direction: column !important;
    }
    
    div.sp-modal .sp-form-actions {
        flex-direction: column !important;
    }
    
    div.sp-modal .sp-btn-primary,
    div.sp-modal .sp-btn-secondary,
    div.sp-modal .sp-btn-danger {
        width: 100% !important;
        flex: none !important;
    }
    
    div.sp-modal .sp-form-row-inline {
        grid-template-columns: 1fr 1fr !important;
    }
}