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

/* Global Variables */
:root {
    --global-bg-color: #2755AA; /* 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: #1F4A99; /* 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 {
    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 {
    --prayerpop-bubble-current-padding: var(--prayerpop-bubble-padding, var(--bubble-padding));
    --prayerpop-bubble-content-size: max(12px, calc(var(--bubble-height) - (var(--prayerpop-bubble-current-padding) * 2)));
    position: fixed;
    bottom: calc(var(--bubble-margin) + var(--bubble-offset-y, 0px));
    right: calc(var(--bubble-margin) + var(--bubble-offset-x, 0px));
    z-index: 999997;
    background-color: var(--global-bg-color);
    color: var(--global-font-color);
    border-radius: var(--global-border-radius);
    padding: var(--prayerpop-bubble-current-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;
}

#prayer-pop-bubble[data-bubble-position="left"] {
    left: calc(var(--bubble-margin) + var(--bubble-offset-x, 0px));
    right: auto;
    transform-origin: bottom left;
}

#prayer-pop-bubble[data-bubble-shape="adaptive"],
#prayer-pop-bubble[data-bubble-shape="dynamic"] {
    width: auto;
    height: var(--bubble-height);
    min-width: max(var(--bubble-height), calc(var(--bubble-height) * var(--prayerpop-icon-scale, 1)));
}

#prayer-pop-bubble[data-bubble-shape="fixed_square"],
#prayer-pop-bubble[data-bubble-shape="square"] {
    width: var(--bubble-height);
    min-width: var(--bubble-height);
    height: var(--bubble-height);
}

#prayer-pop-bubble[data-bubble-shape="fixed_circle"],
#prayer-pop-bubble[data-bubble-shape="circle"] {
    width: var(--bubble-height);
    min-width: var(--bubble-height);
    height: var(--bubble-height);
    border-radius: 9999px;
    overflow: hidden;
    clip-path: circle(50% at 50% 50%);
    -webkit-clip-path: circle(50% at 50% 50%);
}

/* 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: auto;
    height: auto;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    gap: clamp(8px, calc(8px * var(--prayerpop-icon-scale, 1)), 14px);
    white-space: nowrap;
    overflow: visible;
}

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

.prayer-pop-visual-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex: 0 0 auto;
    font-size: calc(clamp(12px, calc(var(--prayerpop-bubble-content-size) * 0.52), 56px) * var(--prayerpop-icon-scale, 1));
}

.prayer-pop-tabler-icon-wrap,
.prayer-pop-brand-icon-wrap {
    width: 1em;
    height: 1em;
    min-width: 1em;
    max-width: 1em;
    min-height: 1em;
    max-height: 1em;
    margin: 0;
    padding: 0;
    box-sizing: content-box;
    flex: 0 0 1em;
}

#prayer-pop-bubble[data-bubble-shape="fixed_square"] #prayer-pop-icon,
#prayer-pop-bubble[data-bubble-shape="square"] #prayer-pop-icon,
#prayer-pop-bubble[data-bubble-shape="fixed_circle"] #prayer-pop-icon,
#prayer-pop-bubble[data-bubble-shape="circle"] #prayer-pop-icon {
    font-size: clamp(20px, calc(var(--prayerpop-bubble-content-size) * 0.66), 44px);
    width: 1em;
    height: 1em;
    min-width: 1em;
    max-width: 1em;
    gap: 0;
    flex: 0 0 1em;
    overflow: visible;
}

#prayer-pop-bubble[data-bubble-shape="fixed_square"] .prayer-pop-icon-text,
#prayer-pop-bubble[data-bubble-shape="square"] .prayer-pop-icon-text,
#prayer-pop-bubble[data-bubble-shape="fixed_circle"] .prayer-pop-icon-text,
#prayer-pop-bubble[data-bubble-shape="circle"] .prayer-pop-icon-text {
    font-size: inherit;
}

#prayer-pop-bubble[data-bubble-shape="fixed_square"][data-bubble-display="icon_text"] .prayer-pop-icon-text,
#prayer-pop-bubble[data-bubble-shape="fixed_square"][data-bubble-display="text_icon"] .prayer-pop-icon-text,
#prayer-pop-bubble[data-bubble-shape="square"][data-bubble-display="icon_text"] .prayer-pop-icon-text,
#prayer-pop-bubble[data-bubble-shape="square"][data-bubble-display="text_icon"] .prayer-pop-icon-text,
#prayer-pop-bubble[data-bubble-shape="fixed_circle"][data-bubble-display="icon_text"] .prayer-pop-icon-text,
#prayer-pop-bubble[data-bubble-shape="fixed_circle"][data-bubble-display="text_icon"] .prayer-pop-icon-text,
#prayer-pop-bubble[data-bubble-shape="circle"][data-bubble-display="icon_text"] .prayer-pop-icon-text,
#prayer-pop-bubble[data-bubble-shape="circle"][data-bubble-display="text_icon"] .prayer-pop-icon-text {
    display: none;
}

#prayer-pop-bubble[data-bubble-shape="fixed_square"] .prayer-pop-visual-icon,
#prayer-pop-bubble[data-bubble-shape="square"] .prayer-pop-visual-icon,
#prayer-pop-bubble[data-bubble-shape="fixed_circle"] .prayer-pop-visual-icon,
#prayer-pop-bubble[data-bubble-shape="circle"] .prayer-pop-visual-icon {
    font-size: calc(1em * var(--prayerpop-icon-scale, 1));
}

#prayer-pop-bubble[data-bubble-display="icon"] .prayer-pop-icon-text {
    display: none;
}

#prayer-pop-bubble[data-bubble-display="text"] .prayer-pop-visual-icon {
    display: none;
}

#prayer-pop-bubble[data-bubble-display="text_icon"] #prayer-pop-icon {
    flex-direction: row-reverse;
}

/* Dashicon Styling */
.prayer-pop-dashicon {
    font-size: 1em;
    width: 1em;
    height: 1em;
    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;
}

.prayer-pop-tabler-icon-wrap .prayer-pop-tabler-icon {
    width: 1em;
    height: 1em;
    display: block;
    stroke: currentColor;
    fill: none;
    margin: auto;
    flex: 0 0 1em;
}

.prayer-pop-brand-icon-wrap .prayer-pop-brand-icon {
    width: 1em;
    height: 1em;
    display: block;
}

/* Mobile Responsive Optimizations */
@media screen and (max-width: 768px) {
    /* Dashicon adjustments */
    .prayer-pop-dashicon {
        font-size: 1em;
        width: 1em;
        height: 1em;
    }
    
    /* 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 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: calc(20px + var(--bubble-offset-y, 0px));
        right: calc(20px + var(--bubble-offset-x, 0px));
    }

    #prayer-pop-modal[data-bubble-position="left"] #prayer-pop-form-container {
        left: calc(20px + var(--bubble-offset-x, 0px));
        right: auto;
    }

    #prayer-pop-bubble[data-bubble-position="left"] {
        left: calc(20px + var(--bubble-offset-x, 0px));
        right: auto;
    }
}

/* Form Container bottom: calc(var(--bubble-height) + var(--bubble-margin) + 20px); */
#prayer-pop-form-container {
    position: fixed;
    right: calc(var(--bubble-margin) + var(--bubble-offset-x, 0px));
    width: 350px;
    background-color: #ffffff;
    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;
    
}

#prayer-pop-modal[data-bubble-position="left"] #prayer-pop-form-container {
    left: calc(var(--bubble-margin) + var(--bubble-offset-x, 0px));
    right: auto;
}

/* Initial Options */
/* 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: 0;
}

/* 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: 12px 16px;
    background-color: rgba(0, 115, 170, 0.1);
    border-radius: var(--global-border-radius);
    box-sizing: border-box;
    font-size: 0.9em;
    color: #666;
    display: none; /* Hidden by default */
    align-items: center;
    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;
}

#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;
}

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

/* Checkbox spacing/layout must beat theme-level #id label/input rules */
#prayer-pop-form .prayer-pop-checkbox-container {
    margin: 0 0 var(--checkbox-margin);
    padding: 0;
}

#prayer-pop-form .prayer-pop-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: calc(var(--global-margin) / 2);
    font-size: var(--global-font-size);
    color: var(--global-label-color);
    cursor: pointer;
    line-height: 1.3;
    margin: 0;
    padding: 0;
}

#prayer-pop-form .prayer-pop-checkbox-label input[type="checkbox"] {
    margin: 0;
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
}
/* Isolated settings preview document. */
.prayer-pop-preview-document,
.prayer-pop-preview-page {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: transparent !important;
}

.prayer-pop-preview-page #wpadminbar {
    display: none !important;
}
/* Dynamic option values are supplied as validated custom properties. */
.prayer-pop-heading,
#prayer-pop-header h2 {
    margin: 0;
    padding: 0;
    color: var(--global-label-color);
    font-family: var(--heading-font-family);
    font-size: var(--heading-font-size);
    font-weight: var(--heading-font-weight);
}

#prayer-pop-bubble {
    background-color: var(--bubble-bg-color, var(--global-bg-color));
    border-radius: var(--bubble-border-radius, var(--global-border-radius));
    transform: scale(var(--prayerpop-bubble-scale, 1)) !important;
}

#prayer-pop-bubble:hover {
    transform: scale(var(--prayerpop-bubble-hover-scale, 1.03)) !important;
}
