/**
 * Gift Calendar Public Module Styles
 *
 * This file contains styles for the public-facing components of the Gift Calendar,
 * including both modal and slideout implementations of the reminder form.
 *
 * IMPORTANT: This version fixes layout issues by:
 * 1. Moving containers out of the document flow
 * 2. Using more scoped CSS selectors
 * 3. Ensuring fixed elements don't affect the layout
 */

/**
 * Trigger Button Containers
 */
.wll-gift-reminder-trigger-container {
    margin: 4px 0 0;
    font-size: 0.85em;
    color: #5d6778;
}

.wll-gift-reminder-bell {
    text-decoration: none;
    display: inline-block;
}

.wll-gift-reminder-heading {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 20px;
    color: #2c3e50;
    font-weight: 600;
}

.wll-gift-reminder-description {
    margin-bottom: 15px;
    color: #5d6778;
    font-size: 14px;
    line-height: 1.5;
}

/* Inline form container */
.wll-gift-reminder-inline {
    max-width: 600px;
    padding: 20px;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Inline alignment modifiers */
.wll-inline-align-left { margin-right: auto; }
.wll-inline-align-center { margin-left: auto; margin-right: auto; }
.wll-inline-align-right { margin-left: auto; }

/* Form wrapper */
.wll-gift-reminder-form-wrapper {
    margin-top: 20px;
    padding: 20px;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wll-form-title {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    color: #2c3e50;
    font-size: 18px;
}

.wll-form-info {
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f5f9ff;
    border-left: 3px solid #3498db;
    border-radius: 3px;
}

.wll-form-info p {
    margin: 0;
    color: #2c3e50;
    font-size: 14px;
}

/* Toggle button */
.wll-gift-reminder-toggle {
    display: inline-block;
    padding: 10px 18px;
    background-color: #3498db;
    color: #fff !important;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
}

.wll-gift-reminder-toggle:hover {
    background-color: #2980b9;
    color: #fff !important;
}

.wll-gift-reminder-toggle .dashicons {
    margin-right: 5px;
    font-size: 18px;
    width: 18px;
    height: 18px;
    vertical-align: text-bottom;
}

/* Form elements */
.wll-gift-reminder-form .form-row {
    margin-bottom: 20px;
}

.wll-gift-reminder-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
}

.wll-gift-reminder-form input[type="text"],
.wll-gift-reminder-form input[type="email"],
.wll-gift-reminder-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    font-size: 14px;
    line-height: 1.4;
    color: #2c3e50;
    transition: border-color 0.3s;
    height: auto;
}

.wll-gift-reminder-form input[type="text"]:focus,
.wll-gift-reminder-form input[type="email"]:focus,
.wll-gift-reminder-form select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 1px rgba(52, 152, 219, 0.3);
    outline: none;
}

.wll-gift-reminder-form input.error,
.wll-gift-reminder-form select.error {
    border-color: #e74c3c;
    background-color: #fff8f8;
}

.wll-gift-reminder-form input[type="checkbox"] {
    margin-right: 8px;
}

.wll-gift-reminder-form .checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.wll-gift-reminder-form .checkbox-text {
    font-weight: normal;
}

.form-description {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #7f8c8d;
    font-style: italic;
}

/* Order Now nudge banner */
.wll-nudge-banner {
    margin-bottom: 20px;
    padding: 16px;
    background-color: #fef9e7;
    border-left: 4px solid #f39c12;
    border-radius: 4px;
}

.wll-nudge-content {
    margin-bottom: 12px;
}

.wll-nudge-heading {
    margin: 0 0 4px;
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
}

.wll-nudge-message {
    margin: 0;
    font-size: 13px;
    color: #5d6778;
}

.wll-nudge-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.wll-nudge-order-now {
    flex: 1;
    padding: 10px 20px !important;
    font-weight: 600;
    text-align: center;
}

.wll-submit-button-secondary {
    flex: 1;
    display: inline-block;
    padding: 10px 16px;
    background: none;
    color: #27ae60;
    border: 1px solid #27ae60;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
}

.wll-submit-button-secondary:hover {
    background-color: #27ae60;
    color: #fff;
}

.wll-submit-button-secondary .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    vertical-align: text-bottom;
    margin-right: 3px;
}

/* No valid reminder options message */
.wll-no-valid-reminder {
    margin-bottom: 20px;
    padding: 12px;
    background-color: #fef9e7;
    border-left: 4px solid #f39c12;
    border-radius: 4px;
    font-size: 13px;
    color: #856404;
}

/* selectWoo / Select2 overrides for product dropdown */
.wll-gift-reminder-form .select2-container--default .select2-selection--single {
    height: 42px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    font-size: 14px;
    color: #2c3e50;
    transition: border-color 0.3s;
}

.wll-gift-reminder-form .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px;
    padding-left: 0;
    color: #2c3e50;
}

.wll-gift-reminder-form .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px;
}

.wll-gift-reminder-form .select2-container--default .select2-selection--single .select2-selection__clear {
    margin-right: 4px;
    font-size: 18px;
    color: #7f8c8d;
}

.wll-gift-reminder-form .select2-container--default.select2-container--open .select2-selection--single,
.wll-gift-reminder-form .select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #3498db;
    box-shadow: 0 0 0 1px rgba(52, 152, 219, 0.3);
    outline: none;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #3498db;
}

.wll-modal-content .select2-container--open .select2-dropdown,
.wll-slideout-content .select2-container--open .select2-dropdown {
    z-index: 1000001;
}

/* Form actions */
.wll-gift-reminder-form .form-actions {
    margin-top: 25px;
}

.wll-submit-button {
    display: inline-block;
    padding: 12px 24px;
    background-color: #27ae60;
    color: #000 !important;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    width: 100%;
}

.wll-submit-button:hover {
    background-color: #219955;
    color: #000 !important;
}

.wll-submit-button .dashicons {
    margin-right: 5px;
    font-size: 18px;
    width: 18px;
    height: 18px;
    vertical-align: text-bottom;
}

/* Privacy notice */
.wll-gift-reminder-form .privacy-notice {
    margin-top: 20px;
    padding: 12px;
    background-color: #f7f7f7;
    border-radius: 4px;
}

.wll-gift-reminder-form .privacy-notice p {
    margin: 0 0 8px;
    font-size: 13px;
    color: #7f8c8d;
    line-height: 1.5;
}

.wll-gift-reminder-form .privacy-notice p:last-child {
    margin-bottom: 0;
}

.wll-gift-reminder-form .privacy-notice a {
    color: #3498db;
    text-decoration: underline;
}

/* Required field indicator */
.wll-gift-reminder-form .required {
    color: #e74c3c;
    margin-left: 3px;
}

/* Error messages */
.wll-form-error-message {
    padding: 12px;
    margin-bottom: 20px;
    background-color: #fdedec;
    border-left: 4px solid #e74c3c;
    color: #c0392b;
    font-size: 14px;
    border-radius: 3px;
}

/* Verification messages */
.wll-gift-verification-success {
    padding: 16px;
    background-color: #edfbf6;
    border-left: 4px solid #27ae60;
    border-radius: 4px;
    color: #27ae60;
    margin-bottom: 20px;
    font-size: 15px;
}

.wll-gift-verification-error {
    padding: 16px;
    background-color: #fdedec;
    border-left: 4px solid #e74c3c;
    border-radius: 4px;
    color: #c0392b;
    margin-bottom: 20px;
    font-size: 15px;
}

/* Date picker customization */
.ui-datepicker {
    z-index: 1000000 !important;
    padding: 10px;
    border: 1px solid #ddd;
    background-color: #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.ui-datepicker .ui-datepicker-header {
    padding: 5px 0;
    background-color: #f5f5f5;
    border-bottom: 1px solid #eee;
    border-radius: 4px 4px 0 0;
}

.ui-datepicker .ui-datepicker-title {
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
}

.ui-datepicker .ui-datepicker-prev,
.ui-datepicker .ui-datepicker-next {
    position: absolute;
    top: 5px;
    width: 20px;
    height: 20px;
    text-align: center;
    cursor: pointer;
    color: #3498db;
}

.ui-datepicker .ui-datepicker-prev {
    left: 5px;
}

.ui-datepicker .ui-datepicker-next {
    right: 5px;
}

.ui-datepicker table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 5px;
}

.ui-datepicker th {
    text-align: center;
    padding: 5px;
    color: #7f8c8d;
    font-size: 12px;
    font-weight: 600;
}

.ui-datepicker td {
    text-align: center;
    padding: 2px;
}

.ui-datepicker td a {
    display: block;
    padding: 5px;
    text-decoration: none;
    text-align: center;
    border-radius: 4px;
    color: #2c3e50;
}

.ui-datepicker td a:hover {
    background-color: #f5f5f5;
}

.ui-datepicker td a.ui-state-active {
    background-color: #3498db;
    color: #fff;
}

.ui-datepicker td a.ui-state-highlight {
    background-color: #f5f9ff;
    border: 1px solid #3498db;
}

/**
 * Button Styles
 */
.wll-gift-reminder-modal-trigger,
.wll-gift-reminder-slideout-trigger {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    cursor: pointer;
    display: inline;
    font-size: 14px;
    font-weight: normal;
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

.wll-gift-reminder-modal-trigger:hover,
.wll-gift-reminder-slideout-trigger:hover {
    opacity: 0.7;
}

.wll-gift-reminder-modal-trigger .dashicons,
.wll-gift-reminder-slideout-trigger .dashicons {
    margin-right: 4px;
    font-size: 16px;
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/**
 * Gift Calendar Containers
 * The parent container for all modals and slideouts
 * Fixed positioning outside the document flow
 */
.wll-gift-calendar-containers {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 0;
    height: 0;
    overflow: hidden;
    visibility: hidden;
}

/**
 * Modal Dialog Styles
 * Completely fixed positioning to avoid layout issues
 */
.wll-gift-reminder-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    display: none;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    pointer-events: none; /* Prevents interaction when closed */
}

.wll-gift-reminder-modal[aria-hidden="false"] {
    display: flex;
    pointer-events: auto; /* Enables interaction when open */
}

.wll-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.wll-modal-container {
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wllModalFadeIn 0.3s ease;
}

.wll-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background-color: #f9f9f9;
}

.wll-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.wll-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #7f8c8d;
    transition: color 0.2s;
}

.wll-modal-close:hover {
    color: #e74c3c;
}

.wll-modal-close .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.wll-modal-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 60px);
}

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

/**
 * Slideout Panel Styles
 * Fixed positioning outside document flow to avoid layout issues
 */
.wll-gift-reminder-slideout {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 420px;
    z-index: 999999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: none;
    pointer-events: none; /* Prevents interaction when closed */
}

.wll-gift-reminder-slideout[aria-hidden="false"] {
    display: block;
    transform: translateX(0);
    pointer-events: auto; /* Enables interaction when open */
}

.wll-slideout-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.wll-slideout-container {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background-color: #fff;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wll-slideout-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background-color: #f9f9f9;
}

.wll-slideout-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.wll-slideout-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #7f8c8d;
    transition: color 0.2s;
}

.wll-slideout-close:hover {
    color: #e74c3c;
}

.wll-slideout-close .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.wll-slideout-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    /* Form fields */
    .wll-gift-reminder-form input[type="text"],
    .wll-gift-reminder-form input[type="email"],
    .wll-gift-reminder-form select {
        font-size: 16px; /* Better for mobile touch */
        padding: 12px;
    }

    .wll-gift-reminder-form .select2-container--default .select2-selection--single {
        height: 46px;
        padding: 8px 12px;
        font-size: 16px;
    }

    .wll-gift-reminder-form .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 28px;
    }

    .wll-gift-reminder-form .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 44px;
    }
    
    .wll-submit-button {
        padding: 14px 20px;
    }
    
    /* Modal specific responsive */
    .wll-modal-container {
        width: 95%;
        max-height: 95vh;
    }
    
    /* Slideout specific responsive */
    .wll-gift-reminder-slideout {
        max-width: 100%;
    }

    /* Inline specific responsive */
    .wll-gift-reminder-inline {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .wll-gift-reminder-heading,
    .wll-modal-title,
    .wll-slideout-title {
        font-size: 18px;
    }
    
    .wll-form-title {
        font-size: 16px;
    }
    
    .wll-modal-header,
    .wll-slideout-header {
        padding: 12px 15px;
    }
    
    .wll-modal-content,
    .wll-slideout-content {
        padding: 15px;
    }

    .wll-nudge-actions {
        flex-direction: column;
    }
}

/* Body overflow control for open modals/slideouts */
body.wll-modal-open,
body.wll-slideout-open {
    overflow: hidden;
    width: 100%;
    /* position: fixed removed to prevent page jump */
}

/**
 * Token Management Page
 */
.wll-token-management .wll-token-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
}

.wll-token-management h1 {
    margin-bottom: 0.25rem;
}

.wll-token-management .wll-email-info {
    color: #666;
    margin-bottom: 2rem;
}

/* Recipient card */
.wll-recipient-card {
    border: 1px solid #e2e2e2;
    border-radius: 6px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.wll-recipient-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

.wll-recipient-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.wll-relationship {
    font-size: 0.85rem;
    color: #888;
}

/* Occasion item */
.wll-occasion-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
}

.wll-occasion-item + .wll-occasion-edit-form + .wll-occasion-item,
.wll-occasion-item + .wll-occasion-item {
    border-top: 1px solid #f0f0f0;
}

.wll-occasion-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.wll-occasion-title {
    font-weight: 600;
    font-size: 1rem;
}

.wll-occasion-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #555;
    font-size: 0.9rem;
}

.wll-recurring-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #0f834d;
    background: #e8f5e9;
    padding: 0.1em 0.5em;
    border-radius: 3px;
}

.wll-reminder-timing {
    font-size: 0.85rem;
    color: #888;
}

/* Action buttons */
.wll-occasion-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.wll-occasion-actions .button {
    padding: 0.4em 1em;
    font-size: 0.85rem;
}

.wll-btn-delete {
    background: none !important;
    border: 1px solid #d2d6dc !important;
    color: #666 !important;
}

.wll-btn-delete:hover {
    border-color: #e2401c !important;
    color: #e2401c !important;
}

.wll-delete-form {
    display: inline;
}

/* Edit form */
.wll-occasion-edit-form {
    margin: 0 0 0.5rem;
    padding: 1.25rem;
    background: #f8f9fa;
    border: 1px solid #e2e2e2;
    border-radius: 6px;
}

.wll-occasion-edit-form .wll-edit-fields {
    overflow: hidden;
}

.wll-occasion-edit-form .form-row {
    margin-bottom: 1rem;
}

.wll-occasion-edit-form .wll-checkbox-row {
    display: flex;
    align-items: flex-end;
    padding-bottom: 0.4rem;
}

.wll-occasion-edit-form .wll-checkbox-row label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    cursor: pointer;
}

.wll-occasion-edit-form .wll-checkbox-row input[type="checkbox"] {
    margin: 0;
}

.wll-edit-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.25rem;
    clear: both;
}

.wll-btn-cancel {
    background: none !important;
    border: 1px solid #d2d6dc !important;
    color: #666 !important;
}

.wll-btn-cancel:hover {
    border-color: #999 !important;
    color: #333 !important;
}

/* Empty state */
.wll-no-reminders {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

/* Footer */
.wll-management-footer {
    text-align: center;
    padding-top: 1rem;
    color: #999;
    font-size: 0.85rem;
}

/* Mobile */
@media (max-width: 600px) {
    .wll-occasion-item {
        flex-direction: column;
        gap: 0.75rem;
    }

    .wll-occasion-actions {
        align-self: flex-start;
    }

    .wll-occasion-edit-form .form-row-first,
    .wll-occasion-edit-form .form-row-last {
        float: none;
        width: 100%;
        margin-right: 0;
    }
}