/**
 * Frontend Styles for Certificate Generator
 * Redesigned for optimal live preview experience
 */

/* ===== CSS Custom Properties ===== */
:root {
    --wpcg-primary: #2563eb;
    --wpcg-primary-dark: #1d4ed8;
    --wpcg-primary-light: #3b82f6;
    --wpcg-secondary: #64748b;
    --wpcg-secondary-dark: #475569;
    --wpcg-success: #10b981;
    --wpcg-bg-dark: #0f172a;
    --wpcg-bg-medium: #1e293b;
    --wpcg-bg-light: #f1f5f9;
    --wpcg-text-primary: #1e293b;
    --wpcg-text-secondary: #64748b;
    --wpcg-border-color: #e2e8f0;
    --wpcg-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --wpcg-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --wpcg-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --wpcg-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --wpcg-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --wpcg-radius-sm: 6px;
    --wpcg-radius-md: 12px;
    --wpcg-radius-lg: 16px;
}

/* ===== Main Container ===== */
.wpcg-certificate-generator {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-sizing: border-box;
}

.wpcg-certificate-generator *,
.wpcg-certificate-generator *::before,
.wpcg-certificate-generator *::after {
    box-sizing: border-box;
}

.wpcg-container {
    width: 100%;
}

/* ===== Template Selector ===== */
.wpcg-template-selector {
    margin: 0 16px 10px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--wpcg-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 10;
}

.wpcg-template-selector label {
    font-weight: 600;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    margin: 0;
}

.wpcg-certificate-generator .wpcg-select {
    all: unset !important;
    flex: 0 1 auto !important;
    min-width: 200px !important;
    max-width: 300px !important;
    padding: 8px 12px !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: var(--wpcg-radius-sm) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    cursor: pointer !important;
    transition: var(--wpcg-transition) !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 14px !important;
    padding-right: 32px !important;
    display: block !important;
    box-sizing: border-box !important;
}

.wpcg-select option {
    background-color: var(--wpcg-bg-dark);
    color: #fff;
}

.wpcg-select:hover {
    border-color: var(--wpcg-primary-light);
    background-color: rgba(255, 255, 255, 0.15);
}

.wpcg-select:focus {
    outline: none;
    border-color: var(--wpcg-primary);
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* ===== Preview Panel - Redesigned ===== */
.wpcg-preview-panel {
    background: linear-gradient(145deg, var(--wpcg-bg-dark) 0%, var(--wpcg-bg-medium) 100%);
    border-radius: var(--wpcg-radius-lg);
    overflow: hidden;
    box-shadow: var(--wpcg-shadow-xl);
    position: relative;
}

.wpcg-preview-panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--wpcg-primary) 0%, var(--wpcg-success) 50%, var(--wpcg-primary-light) 100%);
}

/* Preview Header */
.wpcg-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.wpcg-preview-panel h3 {
    margin: 0;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.wpcg-preview-panel h3::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--wpcg-success);
    border-radius: 50%;
    animation: wpcg-pulse 2s infinite;
}

@keyframes wpcg-pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* Edit Hint Tooltip */
.wpcg-edit-hint {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(16, 185, 129, 0.15) 100%);
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: var(--wpcg-radius-sm);
    padding: 10px 16px;
    margin: 0 24px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
}

.wpcg-edit-hint svg {
    flex-shrink: 0;
    color: var(--wpcg-primary-light);
}

/* ===== Preview Container - Completely Redesigned ===== */
.wpcg-preview-container {
    padding: 24px;
    min-height: 500px;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: visible;
    background:
        radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.03) 0%, transparent 50%),
        repeating-linear-gradient(45deg,
            transparent,
            transparent 10px,
            rgba(255, 255, 255, 0.01) 10px,
            rgba(255, 255, 255, 0.01) 20px);
}

/* Preview Wrapper - Controls scaling */
.wpcg-preview-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Certificate Preview */
.wpcg-certificate-preview {
    background: transparent;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: visible;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s ease;
    transform-origin: center center;
}

.wpcg-certificate-preview:hover {
    box-shadow:
        0 30px 60px -15px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.15);
}

/* Ensure certificate maintains its natural dimensions */
.wpcg-certificate-preview .certificate-container {
    display: block !important;
    overflow: visible !important;
}

/* Zoom Controls */
.wpcg-certificate-generator .wpcg-zoom-controls {
    position: absolute !important;
    bottom: 16px !important;
    right: 24px !important;
    background: rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(8px) !important;
    border-radius: 20px !important;
    display: flex !important;
    align-items: center !important;
    gap: 2px !important;
    padding: 4px !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    z-index: 20 !important;
    width: auto !important;
    height: auto !important;
}

.wpcg-certificate-generator .wpcg-zoom-btn {
    all: unset !important;
    width: 28px !important;
    height: 28px !important;
    border: none !important;
    background: transparent !important;
    color: rgba(255, 255, 255, 0.8) !important;
    cursor: pointer !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
}

.wpcg-certificate-generator .wpcg-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

.wpcg-certificate-generator .wpcg-zoom-btn:active {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: scale(0.95) !important;
}

.wpcg-certificate-generator .wpcg-zoom-btn svg {
    width: 14px !important;
    height: 14px !important;
    display: block !important;
}

.wpcg-certificate-generator .wpcg-zoom-value {
    all: unset !important;
    min-width: 48px !important;
    height: 28px !important;
    border: none !important;
    background: rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    border-radius: 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    padding: 0 8px !important;
}

.wpcg-certificate-generator .wpcg-zoom-value:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

/* ===== Action Buttons ===== */
.wpcg-certificate-generator .wpcg-actions-bottom {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 16px !important;
    flex-wrap: wrap !important;
    background: transparent !important;
}

.wpcg-certificate-generator .wpcg-btn {
    /* Reset theme styles */
    all: unset !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 8px 16px !important;
    border-radius: var(--wpcg-radius-sm) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    text-align: center !important;
    position: relative !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    line-height: 1 !important;
    text-transform: none !important;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

.wpcg-certificate-generator .wpcg-btn-primary {
    background: linear-gradient(135deg, var(--wpcg-primary) 0%, var(--wpcg-primary-dark) 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px 0 rgba(37, 99, 235, 0.4) !important;
    border: none !important;
}

.wpcg-certificate-generator .wpcg-btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px 0 rgba(37, 99, 235, 0.5) !important;
    background: linear-gradient(135deg, var(--wpcg-primary) 0%, var(--wpcg-primary-dark) 100%) !important;
    color: #ffffff !important;
}

.wpcg-certificate-generator .wpcg-btn-secondary {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.wpcg-certificate-generator .wpcg-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    transform: translateY(-2px) !important;
    color: #ffffff !important;
}

.wpcg-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== Modal Styles ===== */
.wpcg-modal {
    display: none;
    position: fixed;
    z-index: 100000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    animation: wpcg-fadeIn 0.2s ease;
}

@keyframes wpcg-fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.wpcg-modal-content {
    background: linear-gradient(145deg, var(--wpcg-bg-dark) 0%, var(--wpcg-bg-medium) 100%);
    margin: 8% auto;
    padding: 32px;
    border-radius: var(--wpcg-radius-lg);
    max-width: 480px;
    width: 90%;
    position: relative;
    box-shadow: var(--wpcg-shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: wpcg-slideUp 0.3s ease;
}

@keyframes wpcg-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wpcg-modal-close {
    color: rgba(255, 255, 255, 0.6);
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--wpcg-transition);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--wpcg-radius-sm);
}

.wpcg-modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.wpcg-modal-content h3 {
    margin: 0 0 24px;
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    border: none;
    padding: 0;
}

.wpcg-modal-content h3::before {
    display: none;
}

.wpcg-form-group {
    margin-bottom: 20px;
}

.wpcg-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

.wpcg-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--wpcg-radius-sm);
    font-size: 15px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    transition: var(--wpcg-transition);
}

.wpcg-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.wpcg-input:focus {
    outline: none;
    border-color: var(--wpcg-primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* ===== Editable Text Styles ===== */
.editable-text {
    cursor: text;
    transition: all 0.2s ease;
    position: relative;
    border-radius: 4px;
}

.editable-text:hover {
    outline: 2px dashed rgba(37, 99, 235, 0.5);
    outline-offset: 4px;
}

.editable-text:focus {
    outline: 2px solid var(--wpcg-primary);
    outline-offset: 4px;
    background-color: rgba(37, 99, 235, 0.08);
}

.editable-text.editing {
    outline: 2px solid var(--wpcg-primary);
    outline-offset: 4px;
    background-color: rgba(37, 99, 235, 0.08);
}

/* ===== Loading State ===== */
.wpcg-loading {
    opacity: 0.6;
    pointer-events: none;
}

.wpcg-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--wpcg-primary);
    border-radius: 50%;
    animation: wpcg-spin 0.8s linear infinite;
}

@keyframes wpcg-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
    .wpcg-certificate-generator {
        padding: 16px;
    }

    .wpcg-preview-container {
        padding: 24px;
        max-height: calc(100vh - 250px);
    }
}

@media (max-width: 768px) {
    .wpcg-certificate-generator {
        padding: 12px;
    }

    .wpcg-template-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .wpcg-select {
        max-width: 100%;
    }

    .wpcg-preview-panel h3 {
        font-size: 14px;
        padding: 12px 16px;
    }

    .wpcg-preview-container {
        padding: 16px;
        min-height: 300px;
        max-height: calc(100vh - 220px);
    }

    .wpcg-edit-hint {
        margin: 0 16px 12px;
        font-size: 12px;
        padding: 8px 12px;
    }

    .wpcg-actions-bottom {
        flex-direction: column;
        padding: 16px;
        gap: 10px;
    }

    .wpcg-btn {
        width: 100%;
        max-width: 320px;
        padding: 14px 24px;
    }

    .wpcg-zoom-controls {
        bottom: 8px;
        right: 12px;
        padding: 3px;
    }

    .wpcg-zoom-btn {
        width: 24px;
        height: 24px;
    }

    .wpcg-zoom-btn svg {
        width: 12px;
        height: 12px;
    }

    .wpcg-zoom-value {
        min-width: 40px;
        height: 24px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .wpcg-certificate-generator {
        padding: 8px;
    }

    .wpcg-preview-panel {
        border-radius: var(--wpcg-radius-md);
    }

    .wpcg-preview-container {
        padding: 12px;
        min-height: 250px;
    }
}

/* ===== Print Styles ===== */
@media print {

    .wpcg-template-selector,
    .wpcg-preview-panel h3,
    .wpcg-actions-bottom,
    .wpcg-edit-hint,
    .wpcg-scale-indicator {
        display: none !important;
    }

    .wpcg-certificate-generator {
        padding: 0;
        max-width: 100%;
    }

    .wpcg-preview-panel {
        background: none;
        box-shadow: none;
        border-radius: 0;
    }

    .wpcg-preview-panel::before {
        display: none;
    }

    .wpcg-preview-container {
        padding: 0;
        max-height: none;
        min-height: auto;
        background: none;
    }

    .wpcg-certificate-preview {
        box-shadow: none !important;
        transform: none !important;
    }
}