/* Avatar Creator Styles */

/* Note: Google Fonts loaded via PHP wp_enqueue_style to avoid mixed content issues */

.avatar-creator-app {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #374151;
    padding: 20px;
}

/* Layout grid - responsive */
.avatar-creator-layout {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
    max-width: 1200px !important;
    margin: 0 auto !important;
}

/* Panel styling */
.avatar-creator-panel {
    background-color: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* Progress Bar Styles */
.progress-bar {
    position: relative;
}

.progress-bar .flex {
    position: relative;
}

.progress-bar .flex::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 10%;
    right: 10%;
    height: 2px;
    background-color: #e5e7eb;
    z-index: 1;
}

.step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    min-width: 80px;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e5e7eb;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.step-indicator.active .step-number {
    background-color: #3b82f6;
    color: white;
}

.step-indicator.completed .step-number {
    background-color: #10b981;
    color: white;
}

.step-label {
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    color: #6b7280;
}

.step-indicator.active .step-label {
    color: #3b82f6;
    font-weight: 600;
}

.step-indicator.completed .step-label {
    color: #10b981;
}

/* Upload Area Styles */
.upload-area {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f9fafb;
    transition: all 0.3s ease;
}

.upload-area:hover {
    background-color: #f3f4f6;
    border-color: #3b82f6;
}

.upload-area.dragover {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

/* Frame Selection Styles */
.frame-option {
    transition: all 0.3s ease;
    background-color: white;
}

.frame-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.frame-option.selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Slider Styles */
.slider {
    -webkit-appearance: none;
    background: linear-gradient(to right, #3b82f6 0%, #3b82f6 50%, #d1d5db 50%, #d1d5db 100%);
    outline: none;
    border-radius: 4px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Preview Container */
.preview-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.preview-result img {
    border: 3px solid white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Preview Area base styles */
#preview-area {
    width: 100%;
    padding: 0;
    margin-bottom: 30px;
}

#preview-area > div {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    margin: 0 auto;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    outline: none;
}

.btn:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-primary:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background-color: #e5e7eb;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Loading Styles */
.loading-overlay {
    backdrop-filter: blur(4px);
}

.loading-spinner {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Error Message Styles */
.error-message {
    border-radius: 8px;
    position: relative;
}

.error-message button {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

/* Control Panel Styles */
.controls-panel {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.preview-panel {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.control-group label {
    margin-bottom: 8px;
}

/* Tip box styles */
.bg-yellow-50 { background-color: #fefce8; }
.border-yellow-200 { border-color: #fde047; }
.text-yellow-600 { color: #ca8a04; }
.text-yellow-700 { color: #a16207; }

/* Responsive Design */
@media (max-width: 768px) {
    .avatar-creator-app {
        padding: 12px;
    }
    
    /* Layout becomes single column on tablet */
    .avatar-creator-layout {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    /* Panel adjustments */
    .avatar-creator-panel {
        padding: 20px;
        border-radius: 16px;
    }
    
    /* Progress bar for tablet */
    .progress-bar .flex::before {
        left: 15%;
        right: 15%;
    }
    
    .step-indicator {
        min-width: 50px;
    }
    
    .step-number {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }
    
    .step-label {
        font-size: 10px;
        max-width: 60px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Frames grid - 4 columns on tablet */
    #frames-container {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        flex-wrap: nowrap !important;
    }
    
    #frames-container > div {
        width: 100% !important;
        height: auto !important;
        max-width: 90px !important;
    }
    
    #frames-container img {
        width: 100% !important;
        height: auto !important;
        max-width: 80px !important;
    }
    
    /* Upload area - tablet */
    #upload-area {
        padding: 25px 15px !important;
        min-height: 160px !important;
    }
    
    #upload-area > div:first-child {
        font-size: 36px !important;
        margin-bottom: 10px !important;
    }
    
    /* Preview area - tablet */
    #preview-area {
        min-height: 350px !important;
        padding: 0 !important;
        margin-bottom: 20px !important;
    }
    
    /* Responsive preview container */
    #preview-area > div {
        max-width: 100% !important;
        width: 350px !important;
        height: 350px !important;
        aspect-ratio: 1 !important;
    }
    
    #preview-area > div > img,
    #preview-area > div > canvas {
        max-width: 100% !important;
        max-height: 100% !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
    }
    
    /* Upload area */
    .upload-area {
        min-height: 180px;
        padding: 20px;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 18px;
        font-size: 13px;
    }
    
    /* Preview images */
    .preview-result img {
        max-width: 100%;
        width: auto !important;
        height: auto !important;
    }
    
    .preview-container .relative img {
        max-width: 100%;
        width: auto !important;
        height: auto !important;
    }
    
    /* Control panels */
    .controls-panel,
    .preview-panel {
        padding: 16px;
    }
    
    .preview-panel {
        margin-bottom: 20px;
    }
    
    /* Two column layout for controls */
    .controls-panel > div[style*="grid"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }
}

@media (max-width: 480px) {
    /* App container */
    .avatar-creator-app {
        padding: 8px;
    }
    
    /* Layout single column */
    .avatar-creator-layout {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        padding: 0 !important;
    }
    
    /* Panel mobile adjustments */
    .avatar-creator-panel {
        padding: 16px !important;
        border-radius: 12px;
    }
    
    /* Progress bar - compact for mobile */
    .progress-bar .flex {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px 0;
    }
    
    .progress-bar .flex::before {
        display: none; /* Hide connecting line on mobile */
    }
    
    .step-indicator {
        min-width: 45px;
        flex-shrink: 0;
    }
    
    .step-number {
        width: 28px;
        height: 28px;
        font-size: 12px;
        margin-bottom: 4px;
    }
    
    .step-label {
        font-size: 9px;
        max-width: 50px;
    }
    
    /* Frames grid - 3 columns on mobile */
    #frames-container {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
    }
    
    #frames-container > div {
        width: 100% !important;
        height: auto !important;
        max-width: 80px !important;
        min-width: 60px !important;
    }
    
    #frames-container img {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        border-radius: 8px !important;
    }
    
    /* Upload area - compact for mobile */
    #upload-area {
        min-height: 100px !important;
        padding: 15px 10px !important;
        border-radius: 12px !important;
    }
    
    #upload-area > div:first-child {
        font-size: 28px !important;
        margin-bottom: 8px !important;
    }
    
    #upload-area > div:nth-child(2) {
        font-size: 13px !important;
        margin-bottom: 5px !important;
    }
    
    #upload-area > div:last-child {
        font-size: 11px !important;
    }
    
    /* Preview area - smaller on mobile */
    #preview-area {
        min-height: 250px !important;
        padding: 0 !important;
        margin-bottom: 16px !important;
    }
    
    /* Let JS control the size, just ensure it fits */
    #preview-area > div {
        max-width: 100% !important;
        max-height: 280px !important;
        width: 280px !important;
        height: 280px !important;
        font-size: 13px !important;
    }
    
    #preview-area > div > img,
    #preview-area > div > canvas {
        max-width: 100% !important;
        max-height: 100% !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
    }
    
    #preview-area canvas {
        max-width: 100% !important;
        max-height: 100% !important;
        width: auto !important;
        height: auto !important;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 12px;
        width: 100%;
    }
    
    /* Button groups */
    div[style*="display: flex"][style*="gap"] button {
        flex: 1;
        min-width: 0;
    }
    
    /* Preview images - responsive */
    .preview-result img {
        max-width: 100%;
        width: auto !important;
        height: auto !important;
    }
    
    .preview-container .relative img {
        max-width: 100%;
        width: auto !important;
        height: auto !important;
    }
    
    /* Control panels adjustments */
    .controls-panel,
    .preview-panel {
        padding: 12px !important;
    }
    
    /* Consistent spacing between sections */
    .avatar-creator-panel > div[style*="margin-bottom"] {
        margin-bottom: 16px !important;
    }
    
    .avatar-creator-panel > h3 {
        margin-bottom: 12px !important;
    }
    
    /* Controls grid - FORCE 2 columns on mobile (Zoom + Rotation) */
    .controls-grid,
    div.controls-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        margin-bottom: 12px !important;
    }
    
    .controls-grid > div,
    div.controls-grid > div {
        width: 100% !important;
    }
    
    .controls-grid label,
    div.controls-grid label {
        font-size: 11px !important;
        margin-bottom: 3px !important;
        display: block !important;
    }
    
    .controls-grid input[type="range"],
    div.controls-grid input[type="range"] {
        width: 100% !important;
        height: 3px !important;
    }
    
    /* AI Section */
    #ai-enable-toggle-box,
    #ai-controls {
        padding: 12px !important;
    }
    
    /* AI Styles buttons */
    #ai-styles {
        gap: 8px !important;
    }
    
    #ai-styles button {
        padding: 8px !important;
        font-size: 11px !important;
    }
    
    /* AI custom prompt */
    #ai-custom-prompt {
        font-size: 13px !important;
        min-height: 80px !important;
    }
    
    /* Modals on mobile */
    #frame-password-modal > div,
    #upload-frame-modal > div {
        width: 95% !important;
        max-width: 95% !important;
        margin: 10px !important;
        padding: 20px !important;
    }
    
    /* Modal buttons */
    #frame-password-modal button,
    #upload-frame-modal button {
        padding: 10px 16px !important;
        font-size: 13px !important;
    }
    
    /* Typography adjustments */
    h3 {
        font-size: 16px !important;
        margin-bottom: 12px !important;
    }
    
    h2 {
        font-size: 18px !important;
        margin-bottom: 16px !important;
    }
    
    p, label {
        font-size: 13px !important;
    }
    
    /* Button text smaller */
    button {
        font-size: 12px !important;
    }
    
    /* Size buttons - stack on mobile */
    #size-buttons {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    #size-buttons button {
        padding: 8px 10px !important;
        font-size: 11px !important;
    }
    
    #size-buttons button > div:first-child {
        font-size: 11px !important;
    }
    
    #size-buttons button > div:last-child {
        font-size: 10px !important;
    }
    
    /* Action buttons - stack on mobile */
    #download-btn,
    #reset-btn,
    #create-avatar-btn {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 13px !important;
        margin-bottom: 8px !important;
    }
    
    /* Button container - stack */
    div[style*="grid-template-columns: 2fr 1fr"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    /* Spacing adjustments */
    .max-w-4xl {
        max-width: 100% !important;
    }
    
    .gap-8 {
        gap: 16px !important;
    }
    
    .p-8 {
        padding: 16px !important;
    }
    
    .p-6 {
        padding: 12px !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets for touch devices */
    .btn {
        min-height: 44px;
        padding: 12px 20px;
    }
    
    .frame-option,
    #frames-container > div,
    .step-indicator {
        min-height: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .frame-option:hover,
    .btn:hover {
        transform: none;
    }
    
    /* Better touch scrolling */
    * {
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1);
    }
}

/* Extra small devices (less than 375px) */
@media (max-width: 374px) {
    .avatar-creator-app {
        padding: 4px;
    }
    
    /* Layout ultra compact */
    .avatar-creator-layout {
        gap: 8px !important;
    }
    
    /* Panel ultra compact */
    .avatar-creator-panel {
        padding: 12px !important;
        border-radius: 8px;
    }
    
    .step-indicator {
        min-width: 40px;
    }
    
    .step-number {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
    
    .step-label {
        font-size: 8px;
        max-width: 40px;
    }
    
    #frames-container {
        gap: 6px !important;
    }
    
    .controls-panel,
    .preview-panel {
        padding: 8px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 11px;
    }
    
    h3 {
        font-size: 14px !important;
    }
    
    h2 {
        font-size: 16px !important;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .progress-bar .flex {
        padding: 5px 0;
    }
    
    .step-indicator {
        min-width: 40px;
    }
    
    .step-number {
        width: 28px;
        height: 28px;
    }
    
    .step-label {
        font-size: 9px;
    }
    
    .preview-panel {
        margin-bottom: 10px;
    }
    
    .upload-area {
        min-height: 120px;
    }
}

/* Custom Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.text-sm { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }
.text-3xl { font-size: 30px; }

.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-800 { color: #1f2937; }
.text-blue-600 { color: #2563eb; }

.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-200 { background-color: #e5e7eb; }
.bg-white { background-color: white; }

.border { border-width: 1px; }
.border-2 { border-width: 2px; }
.border-gray-200 { border-color: #e5e7eb; }
.border-gray-300 { border-color: #d1d5db; }
.border-dashed { border-style: dashed; }

.rounded { border-radius: 4px; }
.rounded-lg { border-radius: 8px; }
.rounded-full { border-radius: 9999px; }

.p-2 { padding: 8px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.p-8 { padding: 32px; }

.px-4 { padding-left: 16px; padding-right: 16px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }

.m-2 { margin: 8px; }
.m-4 { margin: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.mr-3 { margin-right: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }

.mx-auto { margin-left: auto; margin-right: auto; }

.w-full { width: 100%; }
.w-64 { width: 256px; }
.w-80 { width: 320px; }
.h-2 { height: 8px; }
.h-8 { height: 32px; }
.h-12 { height: 48px; }
.h-32 { height: 128px; }

.max-w-4xl { max-width: 896px; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gap-4 { gap: 16px; }
.gap-8 { gap: 32px; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-col { flex-direction: column; }

.relative { position: relative; }
.absolute { position: absolute; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.fixed { position: fixed; }

.z-50 { z-index: 50; }

.cursor-pointer { cursor: pointer; }

.transition-colors { transition-property: color, background-color, border-color; }
.transition-all { transition-property: all; }

.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }

.object-cover { object-fit: cover; }
.object-contain { object-fit: contain; }

.pointer-events-none { pointer-events: none; }

.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }

.bg-opacity-50 { background-color: rgba(0, 0, 0, 0.5); }

/* Missing utility classes */
.text-xs { font-size: 12px; }
.gap-6 { gap: 24px; }

/* Dark theme support (optional) */
@media (prefers-color-scheme: dark) {
    .avatar-creator-app {
        color: #f3f4f6;
    }
    
    .bg-white {
        background-color: #1f2937;
    }
    
    .text-gray-800 {
        color: #f3f4f6;
    }
    
    .text-gray-600 {
        color: #d1d5db;
    }
    
    .border-gray-200 {
        border-color: #374151;
    }
    
    .bg-gray-100 {
        background-color: #374151;
    }
}
