/**
 * Frontend CSS for AMSIT Customise Pro
 *
 * @package AMSIT_Customise_Pro
 */

/* Customization Wrapper */
.amsit-customization-wrapper {
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.amsit-customization-wrapper h3 {
    margin-top: 0;
    color: #333;
    font-size: 24px;
    font-weight: 600;
}

.amsit-customization-wrapper h4 {
    margin: 20px 0 15px 0;
    color: #333;
    font-size: 18px;
    font-weight: 500;
}

/* Upload Grid */
.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin: 15px 0;
}

.upload-area {
    text-align: center;
    cursor: pointer;
}

.upload-circle {
    width: 100px;
    height: 100px;
    border: 2px dashed #ccc;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    margin: 0 auto 10px;
    background: #fff;
}

.upload-circle:hover {
    border-color: #007cba;
    background: #f0f8ff;
    transform: scale(1.05);
}

.upload-circle.drag-over {
    border-color: #007cba;
    background: #e6f3ff;
    transform: scale(1.05);
}

.upload-circle.uploading {
    border-color: #007cba;
    background: #e6f3ff;
}

.upload-circle.uploading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #007cba;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.upload-placeholder {
    text-align: center;
    color: #666;
}

.upload-icon {
    font-size: 24px;
    color: #ccc;
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.upload-text {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.upload-preview {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff4444;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-image:hover {
    background: #cc0000;
    transform: scale(1.1);
}

/* Text Customization */
.text-customization {
    margin: 20px 0;
}

.text-area-input {
    margin-bottom: 15px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.text-area-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.text-customization textarea,
.text-area-input textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    min-height: 80px;
}

.text-customization textarea:focus,
.text-area-input textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.text-customization textarea::placeholder,
.text-area-input textarea::placeholder {
    color: #999;
    font-style: italic;
}

.text-counter {
    text-align: right;
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    font-weight: 500;
}

.text-counter .current-count {
    color: #007cba;
    font-weight: 600;
}

/* Text Preview in Canvas */
.preview-canvas .text-area {
    pointer-events: none;
    word-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
    overflow: hidden;
}

.preview-canvas .text-area .text-preview {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-counter .current-count.warning {
    color: #ff6b35;
    font-weight: bold;
}

/* Preview Section */
/* Generate Preview Section */
.generate-preview-section {
    margin: 20px 0;
    text-align: center;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
}

.preview-section {
    margin: 20px 0;
}

.preview-container {
    text-align: center;
}

.preview-canvas {
    border: 1px solid #ddd;
    margin: 0 auto 15px;
    position: relative;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.template-background {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.image-area {
    border: 2px dashed #ccc !important;
    background: rgba(255, 255, 255, 0.8) !important;
    transition: all 0.3s ease;
}

.image-area:hover {
    border-color: #007cba !important;
    background: rgba(0, 124, 186, 0.1) !important;
}

.area-placeholder {
    font-size: 12px;
    color: #666;
    text-align: center;
    font-weight: 500;
}

.text-area {
    transition: all 0.3s ease;
}

.text-preview {
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.preview-actions {
    margin: 15px 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: #007cba;
    color: white;
}

.btn-primary:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 124, 186, 0.3);
}

.btn-secondary {
    background: #666;
    color: white;
}

.btn-secondary:hover {
    background: #555;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 102, 102, 0.3);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Modal */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.preview-modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.preview-modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #e9ecef;
    color: #333;
}

.modal-body {
    padding: 20px;
    text-align: center;
}

.full-preview-container {
    position: relative;
    display: inline-block;
}

.full-preview-container img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#template-preview-background {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid #ddd;
}

#full-preview-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #ddd;
    text-align: right;
    background: #f8f9fa;
}

.modal-footer .btn {
    margin-left: 10px;
}

/* Notices */
.amsit-notice {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.amsit-notice-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.amsit-notice-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .amsit-customization-wrapper {
        padding: 15px;
        margin: 15px 0;
    }
    
    .upload-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .upload-circle {
        width: 80px;
        height: 80px;
    }
    
    .upload-icon {
        font-size: 20px;
    }
    
    .upload-text {
        font-size: 11px;
    }
    
    .preview-canvas {
        width: 100% !important;
        height: auto !important;
        max-width: 300px;
    }
    
    .preview-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .upload-grid {
        grid-template-columns: 1fr;
    }
    
    .upload-circle {
        width: 70px;
        height: 70px;
    }
    
    .amsit-customization-wrapper h3 {
        font-size: 20px;
    }
    
    .amsit-customization-wrapper h4 {
        font-size: 16px;
    }
}

/* Loading States */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #007cba;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Accessibility */
.upload-area:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .upload-circle {
        border-width: 3px;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .modal-content {
        border: 2px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .upload-circle,
    .btn,
    .modal-content,
    .amsit-notice {
        transition: none;
    }
    
    .upload-circle:hover,
    .btn:hover {
        transform: none;
    }
    
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
}
