/**
 * TT3D Secure Calculator - Frontend Styles
 * 
 * @package TT3D_Secure_Calculator
 * @since 2.0.0
 * @author Mikko Ukkonen, ThunderTuote
 * @copyright 2025 Mikko Ukkonen, ThunderTuote
 *
 * This software is proprietary and confidential.
 * All rights are reserved by the copyright holder.
 *
 * The following restrictions apply:
 * - This plugin may not be copied, shared, redistributed, sublicensed,
 *   sold, decompiled, reverse engineered, or modified in any form.
 * - This plugin may only be used by the license holder on the website
 *   for which it was originally installed.
 * - No part of the source code may be published or made publicly accessible.
 *
 * Unauthorized use, reproduction, disclosure or distribution is strictly
 * prohibited and will result in legal action.
 *
 * © 2025 Mikko Ukkonen — All Rights Reserved.
 */

/* Calculator Wrapper */
.tt3d-calculator-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #2d3748;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* File Upload Fixes */
.tt3d-calculator-wrapper #tt3d_drop_zone {
    cursor: pointer !important;
    pointer-events: auto !important;
    user-select: none;
}

.tt3d-calculator-wrapper #tt3d_drop_zone:hover {
    background-color: rgba(59, 130, 246, 0.05) !important;
    border-color: #3b82f6 !important;
}

.tt3d-calculator-wrapper input[type="file"] {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
}

/* Loading Overlay */
.tt3d-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Messages */
.tt3d-calculator-wrapper .alert {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 8px;
    border: 1px solid;
}

.tt3d-calculator-wrapper .bg-red-50 {
    background-color: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.tt3d-calculator-wrapper .bg-green-50 {
    background-color: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.tt3d-calculator-wrapper .bg-blue-50 {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

.tt3d-loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 1.1rem;
}

/* Spinner Animation */
.tt3d-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: tt3d-spin 1s linear infinite;
}

@keyframes tt3d-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* File Drop Zone */
.tt3d-calculator-wrapper .border-dashed {
    border-style: dashed !important;
    transition: all 0.3s ease;
}

.tt3d-calculator-wrapper .border-dashed:hover {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

.tt3d-calculator-wrapper .border-dashed.drag-over {
    border-color: #3b82f6;
    background-color: #dbeafe;
    transform: scale(1.02);
}

/* File List Styles */
#tt3d_file_list {
    animation: tt3d-fadeIn 0.3s ease-in;
}

@keyframes tt3d-fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tt3d-file-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.tt3d-file-item:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.tt3d-file-item.processing {
    opacity: 0.6;
}

.tt3d-file-item .file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tt3d-file-item .file-details {
    font-size: 0.875rem;
}

.tt3d-file-item .file-name {
    font-weight: 500;
    color: #2d3748;
}

.tt3d-file-item .file-meta {
    color: #718096;
    font-size: 0.75rem;
    margin-top: 2px;
}

/* 3D Preview Canvas */
#tt3d_preview {
    background: linear-gradient(135deg, #f6f8fb 0%, #e9ecef 100%);
    border-radius: 8px;
    cursor: grab;
}

#tt3d_preview:active {
    cursor: grabbing;
}

/* Model Navigation */
#tt3d_model_nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

#tt3d_model_nav button {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
}

#tt3d_model_nav button:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

#tt3d_model_nav button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#tt3d_model_counter {
    font-weight: 500;
    color: #2d3748;
    font-size: 0.875rem;
}

/* Form Controls */
.tt3d-calculator-wrapper input,
.tt3d-calculator-wrapper select {
    appearance: none;
    background: white;
    border: 1px solid #d2d6dc;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    width: 100%;
}

.tt3d-calculator-wrapper input:focus,
.tt3d-calculator-wrapper select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.tt3d-calculator-wrapper label {
    display: block;
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
    font-size: 0.875rem;
}

/* Buttons */
.tt3d-calculator-wrapper button {
    font-weight: 600;
    border-radius: 8px;
    padding: 12px 24px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.875rem;
}

.tt3d-calculator-wrapper button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.tt3d-calculator-wrapper button:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Primary Button */
.tt3d-calculator-wrapper .btn-primary {
    background: #3b82f6;
    color: white;
}

.tt3d-calculator-wrapper .btn-primary:not(:disabled):hover {
    background: #2563eb;
}

/* Success Button */
.tt3d-calculator-wrapper .btn-success {
    background: #10b981;
    color: white;
}

.tt3d-calculator-wrapper .btn-success:not(:disabled):hover {
    background: #059669;
}

/* Price Display */
#tt3d_total_price {
    font-size: 2.5rem;
    font-weight: 800;
    color: #3b82f6;
    text-align: center;
    margin: 1rem 0;
    transition: all 0.3s ease;
}

#tt3d_total_price.updated {
    animation: tt3d-priceUpdate 0.5s ease;
}

@keyframes tt3d-priceUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Price Breakdown */
#tt3d_breakdown {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin: 1rem 0;
}

#tt3d_breakdown h4 {
    margin: 0 0 12px 0;
    font-weight: 600;
    color: #2d3748;
    font-size: 0.875rem;
}

.tt3d-breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.875rem;
}

.tt3d-breakdown-row.total {
    border-top: 1px solid #e2e8f0;
    margin-top: 8px;
    padding-top: 8px;
    font-weight: 600;
}

/* Model Details */
#tt3d_model_details {
    background: #f8fafc;
    border-radius: 8px;
    padding: 16px;
    margin: 1rem 0;
}

.tt3d-model-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.tt3d-model-item:hover {
    border-color: #cbd5e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tt3d-model-item.active {
    border-color: #3b82f6;
    background: #eff6ff;
}

.tt3d-model-item .model-name {
    font-weight: 500;
    color: #2d3748;
    font-size: 0.875rem;
}

.tt3d-model-item .model-meta {
    color: #718096;
    font-size: 0.75rem;
    margin-top: 4px;
}

.tt3d-supports-warning {
    color: #f59e0b;
    font-weight: 500;
}

/* Error Messages */
#tt3d_error_messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.tt3d-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: tt3d-slideIn 0.3s ease;
}

.tt3d-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: tt3d-slideIn 0.3s ease;
}

@keyframes tt3d-slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Cart Summary */
.tt3d-cart-summary {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 4px;
}

/* Order Meta Display */
.tt3d-order-models {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0;
    font-size: 0.875rem;
}

.tt3d-order-models strong {
    color: #374151;
}

/* Responsive Design */
@media (max-width: 768px) {
    .tt3d-calculator-wrapper {
        padding: 0.5rem;
    }
    
    .tt3d-calculator-wrapper .grid {
        display: block;
    }
    
    .tt3d-calculator-wrapper .lg\\:col-span-2,
    .tt3d-calculator-wrapper .lg\\:col-span-1 {
        margin-bottom: 1rem;
    }
    
    #tt3d_total_price {
        font-size: 2rem;
    }
    
    .tt3d-calculator-wrapper .md\\:grid-cols-2 {
        grid-template-columns: 1fr;
    }
    
    .tt3d-calculator-wrapper .lg\\:grid-cols-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .tt3d-calculator-wrapper {
        padding: 0.25rem;
    }
    
    .tt3d-calculator-wrapper .p-6 {
        padding: 1rem;
    }
    
    .tt3d-calculator-wrapper .gap-6 {
        gap: 1rem;
    }
    
    #tt3d_total_price {
        font-size: 1.75rem;
    }
    
    .tt3d-calculator-wrapper .grid {
        gap: 0.5rem;
    }
    
    #tt3d_error_messages {
        left: 10px;
        right: 10px;
        top: 10px;
        max-width: none;
    }
}

/* Print Styles */
@media print {
    .tt3d-loading-overlay,
    #tt3d_error_messages,
    .tt3d-calculator-wrapper button {
        display: none !important;
    }
    
    .tt3d-calculator-wrapper {
        max-width: none;
        padding: 0;
    }
    
    #tt3d_preview {
        height: 200px !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .tt3d-calculator-wrapper {
        border: 2px solid #000;
    }
    
    .tt3d-calculator-wrapper button {
        border: 2px solid #000;
    }
    
    .tt3d-calculator-wrapper input,
    .tt3d-calculator-wrapper select {
        border: 2px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .tt3d-spinner {
        animation: none;
        border-top-color: #3b82f6;
    }
}

/* Focus Styles for Accessibility */
.tt3d-calculator-wrapper *:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.tt3d-calculator-wrapper button:focus {
    outline-offset: 4px;
}

/* Utility Classes */
.tt3d-hidden { display: none !important; }
.tt3d-visible { display: block !important; }
.tt3d-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}