/* assets/css/prayer-pop.css */

/* Global Variables */
:root {
    --global-bg-color: #0073aa; /* Default global color for bubble and button */
    --global-font-color: #ffffff; /* White for text */
    --global-label-color: #333333; /* Dark gray for label text */
    --global-button-hover-color: #3E6851; /* Hover color for button and bubble */
    --global-textarea-bg-color: #f9f9f9; /* Light gray for textarea background */
    --global-border-color: #ddd; /* Border color for inputs */
    --global-border-radius: 8px; /* Global border radius */
    --global-padding: 15px; /* Global padding */
    --global-margin: 15px; /* Global margin */
    --global-font-size: 16px; /* Global font size */
    --global-bold-font-weight: bold; /* Global bold font weight */
    --global-font-family: system-ui; /* Global font family */
    
    /* Heading-specific variables */
    --heading-font-family: var(--global-font-family); /* Heading font family */
    --heading-font-size: 24px; /* Heading font size */
    --heading-font-weight: 600; /* Heading font weight */
    
    /* Bubble-specific variables */
    --bubble-padding: 15px; /* Bubble padding */
    --bubble-margin: 20px; /* Bubble margin */
    --bubble-height: 60px; /* Bubble height */
    
    /* Checkbox-specific variables */
    --checkbox-margin: 8px; /* Checkbox spacing (smaller than global margin) */
}

/* Apply global font family to all elements */
#prayer-pop-bubble,
#prayer-pop-form-container,
#prayer-pop-form textarea,
#prayer-pop-form input[type="text"],
#prayer-pop-form button[type="submit"],
#prayer-pop-new-request,
.prayer-pop-button,
#prayer-pop-success,
#prayer-pop-error,
#prayer-pop-header h2,
#prayer-pop-description p,
#prayer-pop-last-time,
.prayer-pop-request-content,
.prayer-pop-request-meta,
.prayer-pop-request-author,
.prayer-pop-request-time,
.prayer-pop-i-prayed-button,
.prayer-pop-i-prayed-count {
    font-family: var(--global-font-family);
}

/* No Animation (Default) */
#prayer-pop-bubble.none,
#prayer-pop-form-container.none {
    opacity: 1;
    transform: none;
}

/* Fade In Animation */
@keyframes prayerpop-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

#prayer-pop-bubble.fade-in,
#prayer-pop-form-container.fade-in {
    animation: prayerpop-fade-in 0.5s forwards;
}

/* Slide In from Bottom Animation */
@keyframes prayerpop-slide-up {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

#prayer-pop-bubble.slide-up,
#prayer-pop-form-container.slide-up {
    animation: prayerpop-slide-up 0.5s forwards;
}

/* Bounce In Animation */
@keyframes prayerpop-bounce-in {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

#prayer-pop-bubble.bounce-in,
#prayer-pop-form-container.bounce-in {
    animation: prayerpop-bounce-in 0.5s forwards;
}

/* Bubble Styles */
#prayer-pop-bubble {
    position: fixed;
    bottom: var(--bubble-margin);
    right: var(--bubble-margin);
    z-index: 999997;
    background-color: var(--global-bg-color);
    color: var(--global-font-color);
    border-radius: var(--global-border-radius);
    padding: var(--bubble-padding);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--bubble-height);
    height: var(--bubble-height);
    font-size: var(--global-font-size);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-align: center;
    box-sizing: border-box;
    transform-origin: bottom right;
}

/* When form container is visible, adjust bubble position */
#prayer-pop-modal:not([style*="display: none"]) ~ #prayer-pop-bubble {
    transform: translateY(0);
}

/* Hover Animation */
#prayer-pop-bubble:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Chat Bubble Icon */
#prayer-pop-icon {
    font-size: var(--global-font-size);
    font-weight: bold;
    color: var(--global-font-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Bubble Icon Text */
.prayer-pop-icon-text {
    font-size: var(--global-font-size);
    font-weight: bold;
    color: var(--global-font-color);
}

/* Dashicon Styling */
.prayer-pop-dashicon {
    font-size: 24px;
    width: 24px;
    height: 24px;
    line-height: 1;
    color: var(--global-font-color);
    transition: transform 0.3s ease;
    font-family: dashicons;
    font-weight: normal;
    font-style: normal;
    speak: never;
    display: inline-block;
    text-decoration: inherit;
    text-transform: none;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom Image Styling */
.prayer-pop-custom-image {
    max-width: 32px;
    max-height: 32px;
    border-radius: 4px;
    transition: transform 0.3s ease;
}

/* Aspect Ratio 1:1 for images */
[data-icon-type="custom_image"] .prayer-pop-custom-image {
    width: 32px;
    height: 32px;
    object-fit: cover;
}

/* Icon hover effects */
#prayer-pop-bubble:hover .prayer-pop-dashicon,
#prayer-pop-bubble:hover .prayer-pop-custom-image {
    transform: scale(1.1);
}

/* Mobile Responsive Optimizations */
@media screen and (max-width: 768px) {
    /* Dashicon adjustments */
    .prayer-pop-dashicon {
        font-size: 20px;
        width: 20px;
        height: 20px;
    }
    
    .prayer-pop-custom-image {
        max-width: 28px;
        max-height: 28px;
    }
    
    [data-icon-type="custom_image"] .prayer-pop-custom-image {
        width: 28px;
        height: 28px;
    }
    
    /* Optimize modal positioning and spacing for mobile */
    #prayer-pop-form-container {
        width: calc(100vw - 40px);
        max-width: 400px;
        right: 20px;
        bottom: calc(var(--bubble-height) + var(--bubble-margin) + 10px);
        padding: 15px;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
    
    /* Reduce spacing between elements on mobile */
    #prayer-pop-initial-options {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    /* Optimize button padding */
    .prayer-pop-option-button,
    .prayer-pop-custom-button {
        padding: 12px 15px;
        font-size: 16px;
    }
    
    /* Reduce header margins */
    #prayer-pop-header {
        margin-bottom: 10px;
    }
    
    #prayer-pop-description {
        margin-bottom: 15px;
    }
    
    /* Optimize form spacing */
    #prayer-pop-form textarea {
        margin-bottom: 12px;
        min-height: 100px;
    }
    
    #prayer-pop-name-container {
        margin-bottom: 12px;
    }
    
    .prayer-pop-checkbox-container {
        margin-bottom: 6px;
    }
    
    /* Reduce back button margin */
    #prayer-pop-back-button {
        margin-bottom: 10px;
    }
    
    /* Optimize bubble for mobile */
    #prayer-pop-bubble {
        bottom: 20px;
        right: 20px;
    }
}

/* Form Container bottom: calc(var(--bubble-height) + var(--bubble-margin) + 20px); */
#prayer-pop-form-container {
    position: fixed;
    right: var(--bubble-margin);
    width: 350px;
    background-color: #ffffff !important;
    border-radius: var(--global-border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: var(--global-padding);
    border: none;
    font-size: var(--global-font-size);
    opacity: 1;
    z-index: 999998;
    transition: transform 0.3s ease, opacity 0.3s ease;
    
}

/* Initial Options */
#prayer-pop-initial-options {
    display: flex;
    flex-direction: column;
    gap: var(--global-margin);
}

/* Option and Custom Buttons */
.prayer-pop-option-button,
.prayer-pop-custom-button {
    width: 100%;
    background-color: var(--global-bg-color);
    color: var(--global-font-color);
    border: none;
    border-radius: var(--global-border-radius);
    padding: var(--global-padding);
    font-size: var(--global-font-size);
    font-weight: var(--global-bold-font-weight);
    cursor: pointer;
    text-align: center;
    transition: background-color 0.3s ease;
}

.prayer-pop-option-button:hover,
.prayer-pop-custom-button:hover {
    background-color: var(--global-button-hover-color);
}

/* Back Button */
#prayer-pop-back-button {
    background: none;
    border: none;
    color: var(--global-label-color);
    font-size: var(--global-font-size);
    cursor: pointer;
    margin-bottom: calc(var(--global-margin));
    text-align: left;
}

#prayer-pop-back-button:hover {
    text-decoration: underline;
}

/* Form Styling */
#prayer-pop-form {
    display: flex;
    flex-direction: column;
    gap: var(--global-margin);
}

/* Text Area */
#prayer-pop-form textarea {
    width: 100%;
    margin-bottom: var(--global-margin);
    padding: var(--global-padding);
    border: 1px solid var(--global-border-color);
    border-radius: var(--global-border-radius);
    font-size: var(--global-font-size);
    background-color: var(--global-textarea-bg-color);
    color: var(--global-label-color);
    box-sizing: border-box;
    height: 120px;
    resize: vertical;
}

#prayer-pop-form textarea::placeholder {
    color: var(--global-label-color);
    opacity: 0.7;
}

/* Input Field - No margin as containers handle spacing */
#prayer-pop-form input[type="text"] {
    width: 100%;
    margin: 0;
    padding: var(--global-padding);
    border: 1px solid var(--global-border-color);
    border-radius: var(--global-border-radius);
    font-size: var(--global-font-size);
    background-color: var(--global-textarea-bg-color);
    box-sizing: border-box;
}

/* Submit Button */
#prayer-pop-form button[type="submit"] {
    width: 100%;
    background-color: var(--global-bg-color);
    color: var(--global-font-color);
    border: none;
    border-radius: var(--global-border-radius);
    padding: var(--global-padding);
    font-size: var(--global-font-size);
    font-weight: var(--global-bold-font-weight);
    cursor: pointer;
    text-align: center;
    transition: background-color 0.3s ease;
    margin-top: calc(var(--global-margin) / 2);
}

#prayer-pop-form button[type="submit"]:hover {
    background-color: var(--global-button-hover-color);
}

/* Success and Error Messages */
#prayer-pop-success,
#prayer-pop-error {
    padding: var(--global-padding);
    border-radius: var(--global-border-radius);
    margin: var(--global-margin) 0;
    font-size: var(--global-font-size);
    text-align: left;
}

#prayer-pop-success {
    background-color: #dff0d8;
    color: #3c763d;
    border: 1px solid #d6e9c6;
}

#prayer-pop-error {
    background-color: #f2dede;
    color: #a94442;
    border: 1px solid #ebccd1;
}

/* Form Modal */
#prayer-pop-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
}

/* Header Style */
#prayer-pop-header {
    margin-bottom: calc(var(--global-margin) / 2);
}

.prayer-pop-heading,
#prayer-pop-header h2 {
    font-size: var(--heading-font-size);
    color: var(--global-label-color);
    margin: 0;
    padding: 0;
    font-weight: var(--heading-font-weight);
    font-family: var(--heading-font-family);
}

/* Description Style */
#prayer-pop-description {
    margin-bottom: var(--global-margin);
}

#prayer-pop-description p {
    font-size: var(--global-font-size);
    color: var(--global-label-color);
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

/* Adjust form wrapper */
#prayer-pop-form-wrapper {
    display: flex;
    flex-direction: column;
}

/* Last Time Message */
#prayer-pop-last-time {
    margin-bottom: var(--global-margin);
    padding: 5px 5px;
    background-color: rgba(0, 115, 170, 0.1);
    border-radius: var(--global-border-radius);
    font-size: 0.9em;
    color: #666;
    display: none; /* Hidden by default */
    align-items: center;
    gap: 8px;
    transition: opacity 0.3s ease;
    opacity: 1;
}

/* Only show timer when in form view and has content */
#prayer-pop-form-wrapper:not(.initial-view) #prayer-pop-last-time:not(:empty) {
    display: flex;
}

/* Hide timer completely when empty or in initial view */
#prayer-pop-form-wrapper.initial-view #prayer-pop-last-time,
#prayer-pop-last-time:empty {
    display: none !important;
    opacity: 0;
}

/* Form Wrapper States */
#prayer-pop-form-wrapper {
    position: relative;
}

#prayer-pop-form-wrapper.initial-view #prayer-pop-last-time {
    display: none !important;
}

/* Masonry Layout Styles */
.prayer-pop-requests {
    column-count: 3;
    column-gap: var(--global-margin);
    width: 100%;
}

.prayer-pop-request {
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: var(--global-margin);
    background: linear-gradient(to bottom, color-mix(in srgb, var(--global-bg-color), white 75%) 45px, var(--global-textarea-bg-color) 0);
    padding: var(--global-padding);
    border-radius: var(--global-border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    break-inside: avoid;
    padding-bottom: 10px;
    min-width: 0; /* Ensure cards can shrink */
    opacity: 1; /* Ensure cards are visible */
}

@media screen and (max-width: 1150px) and (min-width: 769px) {
    .prayer-pop-requests {
        column-count: 2;
    }
}

@media screen and (max-width: 768px) {
    /* Hide toggle switch on mobile/tablet */
    .prayer-pop-toggle-container {
        display: none !important;
    }

    /* Force single column layout on mobile/tablet */
    .prayer-pop-requests {
        column-count: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    .prayer-pop-request {
        break-inside: auto !important;
        margin-bottom: 0 !important; /* Use gap instead */
        width: 100% !important;
        display: block !important;
        position: static !important; /* Override any masonry positioning */
        opacity: 1 !important;
        visibility: visible !important;
        height: auto !important;
    }
    
    /* Hide problematic Divi code modules only if they're empty */
    .et_pb_code.et_pb_code_0:empty {
        display: none !important;
    }
}

.prayer-pop-request-content {
    margin-bottom: var(--global-margin);
    margin-top: var(--global-margin);
    padding-top: 10px;
}

.prayer-pop-request-meta {
    font-size: 14px;
    color: #777;
    margin-bottom: 10px;
}

.prayer-pop-request-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.prayer-pop-request-author {
    font-weight: bold;
    font-size: 0.9em;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    line-height: 1.2;
}

/* Adjust spacing for multi-line names */
.prayer-pop-request-author.multi-line {
    margin-top: -10px;
    line-height: 1.1;
}

/* Adjust font size for longer names */
.prayer-pop-request-author.long-name {
    font-size: 0.8em;
}

.prayer-pop-request-author.very-long-name {
    font-size: 0.75em;
}

.prayer-pop-request-time {
    font-style: italic;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.85em;
}

.prayer-pop-i-prayed {
    border-top: 1px solid #ededed;
    padding-top: 15px;
    display: flex;
    align-items: center;
}

.prayer-pop-i-prayed-button {
    background-color: var(--global-bg-color);
    color: #fff;
    border: none;
    font-weight: 600;  
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 5px;
    margin-right: 10px;
}

.prayer-pop-i-prayed-button[disabled] {
    background-color: color-mix(in srgb, var(--global-bg-color), rgb(240, 240, 240) 95%);
    font-weight: 600;  
    cursor: not-allowed;
}

.prayer-pop-i-prayed-count {
    font-size: 14px;
    color: #666;
}

#prayer-pop-new-request,
.prayer-pop-button {
    width: 100%;
    background-color: var(--global-bg-color);
    color: var(--global-font-color);
    border: none;
    border-radius: var(--global-border-radius);
    padding: var(--global-padding);
    font-size: var(--global-font-size);
    font-weight: var(--global-bold-font-weight);
    cursor: pointer;
    text-align: center;
    transition: background-color 0.3s ease;
}

#prayer-pop-new-request:hover,
.prayer-pop-button:hover {
    background-color: #005a8c;
}

/* List View */
.prayer-pop-requests.prayer-pop-display-list {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.prayer-pop-requests.prayer-pop-display-list .prayer-pop-request {
    width: 100%;
    box-sizing: border-box;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: var(--global-border-radius);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

/* Name container - handles margin for name input */
#prayer-pop-name-container {
    margin-bottom: var(--global-margin);
}

/* Checkbox container styles - smaller margin for checkboxes */
.prayer-pop-checkbox-container {
    margin-bottom: var(--checkbox-margin);
}

/* Checkbox label styles */
.prayer-pop-checkbox-label {
    display: flex;
    align-items: center;
    gap: calc(var(--global-margin) / 2);
    font-size: var(--global-font-size);
    color: var(--global-label-color);
    cursor: pointer;
}

/* Checkbox input styles */
.prayer-pop-checkbox-label input[type="checkbox"] {
    margin: 0;
    padding: 0;
    cursor: pointer;
}
