/**
 * Add to Moodboard Widget Styles
 * 
 * @package CemPorcentoMoodboard
 */

/* Button Wrapper */
.cpm-add-button-wrapper {
    display: inline-block;
    width: 100%;
}

/* Add to Moodboard Button */
.cpm-add-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: #f2f2f2;
    color: #F18223;
    border: 1px solid #F18223;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    max-width: 418px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.cpm-add-button:hover {
    background-color: #F18223;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 106, 0, 0.3);
}

.cpm-add-button:focus {
    outline: none;
}

.cpm-add-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.cpm-add-button.loading {
    opacity: 0.8;
    cursor: wait;
}

.cpm-add-button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: cpm-spin 1s linear infinite;
}

.cpm-add-button.loading .cpm-button-text,
.cpm-add-button.loading .cpm-button-icon {
    opacity: 0;
}

/* Button Icon */
.cpm-button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.cpm-button-icon svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

/* Button Text */
.cpm-button-text {
    white-space: nowrap;
}

/* Modal Overlay */
.cpm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.cpm-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Prevent scrolling when modal is open */
body.cpm-modal-open {
    overflow: hidden;
}

/* Modal Content */
.cpm-modal-content {
    background: #ffffff;
    border-radius: 12px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
}

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

/* Modal Close Button */
.cpm-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: color 0.3s ease;
}

.cpm-modal-close:hover {
    color: #333;
}

/* Modal Header */
.cpm-modal-title {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.cpm-modal-subtitle {
    margin: 0 0 24px 0;
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

/* Modal Body */
.cpm-modal-body {
    margin-bottom: 24px;
}

/* Loading State */
.cpm-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

/* Moodboards List */
.cpm-moodboards-list {
    margin-bottom: 20px;
}

.cpm-moodboards-container {
    min-height: 50px;
}

.cpm-no-moodboards {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
    margin: 0;
}

.cpm-error {
    color: #dc3545;
    text-align: center;
    padding: 20px;
    margin: 0;
}

/* Moodboards Grid */
.cpm-moodboards-grid {
    display: grid;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom Scrollbar */
.cpm-moodboards-grid::-webkit-scrollbar {
    width: 6px;
}

.cpm-moodboards-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.cpm-moodboards-grid::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.cpm-moodboards-grid::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Moodboard Option */
.cpm-moodboard-option {
    position: relative;
    cursor: pointer;
    display: block;
    margin: 0;
}

.cpm-moodboard-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    left: -9999px;
}

.cpm-moodboard-card {
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: #ffffff;
}

.cpm-moodboard-option:hover .cpm-moodboard-card {
    border-color: #FF6A00;
    box-shadow: 0 2px 8px rgba(255, 106, 0, 0.1);
}

.cpm-moodboard-option input[type="radio"]:checked + .cpm-moodboard-card {
    border-color: #FF6A00;
    background: #fff8f5;
    box-shadow: 0 2px 12px rgba(255, 106, 0, 0.2);
}

.cpm-moodboard-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.cpm-moodboard-description {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.cpm-moodboard-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #999;
}

.cpm-item-count {
    font-weight: 500;
    color: #FF6A00;
}

/* New Moodboard Option */
.cpm-new-moodboard-option {
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
    margin-top: 20px;
}

.cpm-new-moodboard-option label {
    display: block;
    cursor: pointer;
    margin: 0;
}

.cpm-new-moodboard-option input[type="radio"] {
    margin-right: 8px;
}

.cpm-new-moodboard-text {
    font-weight: 500;
    color: #FF6A00;
}

.cpm-new-moodboard-fields {
    margin-top: 12px;
    padding-left: 24px;
}

.cpm-new-moodboard-title {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.cpm-new-moodboard-title:focus {
    outline: none;
    border-color: #FF6A00;
    box-shadow: 0 0 0 2px rgba(255, 106, 0, 0.1);
}

/* Modal Footer */
.cpm-modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.cpm-modal-cancel,
.cpm-modal-add {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cpm-modal-cancel {
    background: #f5f5f5;
    color: #666;
}

.cpm-modal-cancel:hover {
    background: #e0e0e0;
}

.cpm-modal-add {
    background: #FF6A00;
    color: #ffffff;
    position: relative;
    overflow: hidden;
}

.cpm-modal-add:hover:not(:disabled) {
    background: #E55A00;
}

.cpm-modal-add:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.cpm-modal-add.loading {
    opacity: 0.8;
    cursor: wait;
}

.cpm-modal-add.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: cpm-spin 1s linear infinite;
}

/* Message Notifications */
.cpm-message-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 20px;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000000;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    transform: translateX(100%);
    display: none;
}

.cpm-message-notification:hover {
    transform: translateX(0) scale(1.02);
}

.cpm-message-success {
    background: #28a745;
    border-left: 4px solid #1e7e34;
}

.cpm-message-error {
    background: #dc3545;
    border-left: 4px solid #c82333;
}

.cpm-message-info {
    background: #17a2b8;
    border-left: 4px solid #138496;
}

.cpm-message-notification a {
    color: #ffffff;
    text-decoration: underline;
    font-weight: 600;
}

.cpm-message-notification a:hover {
    text-decoration: none;
}

/* Animations */
@keyframes cpm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .cpm-modal-content {
        width: 95%;
        padding: 20px;
        margin: 20px;
        max-height: 85vh;
    }
    
    .cpm-modal-title {
        font-size: 18px;
    }
    
    .cpm-modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
    }
    
    .cpm-modal-cancel,
    .cpm-modal-add {
        width: 100%;
        padding: 12px;
    }
    
    .cpm-moodboard-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .cpm-message-notification {
        right: 10px;
        left: 10px;
        max-width: none;
        top: 10px;
    }
}

@media (max-width: 480px) {
    .cpm-add-button {
        width: 100%;
        justify-content: center;
    }
    
    .cpm-modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .cpm-moodboards-grid {
        max-height: 250px;
    }
}

/* Elementor Editor Styles */
.elementor-editor-active .cpm-add-button {
    pointer-events: none;
}

.elementor-editor-active .cpm-add-button-preview {
    border: 2px dashed #ccc;
    padding: 20px;
    text-align: center;
    border-radius: 8px;
    background: #f9f9f9;
}

.elementor-editor-active .cpm-add-button-preview p {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 14px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .cpm-modal-overlay {
        background-color: rgba(0, 0, 0, 0.8);
    }
    
    .cpm-moodboard-card {
        border-width: 3px;
    }
    
    .cpm-add-button:focus {
        box-shadow: 0 0 0 4px rgba(255, 106, 0, 0.5);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .cpm-add-button,
    .cpm-modal-overlay,
    .cpm-modal-content,
    .cpm-moodboard-card,
    .cpm-message-notification {
        transition: none;
    }
    
    .cpm-add-button.loading::after,
    .cpm-modal-add.loading::after {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .cpm-modal-overlay,
    .cpm-message-notification {
        display: none !important;
    }
}