/* css/styles.css - Modern Image Framer Styles with Fixed Button Focus States */

:root {
    --primary-blue: #2F3292;
    --light-blue: #7BAADA;
    --lighter-blue: #D2E4F3;
    --red-accent: #BF3841;
    --white: #FFFFFF;
    --gradient-primary: linear-gradient(135deg, var(--primary-blue) 0%, var(--light-blue) 100%);
    --gradient-secondary: linear-gradient(135deg, var(--lighter-blue) 0%, var(--white) 100%);
    --shadow-soft: 0 4px 20px rgba(47, 50, 146, 0.08);
    --shadow-medium: 0 8px 30px rgba(47, 50, 146, 0.12);
    --border-radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Ubuntu', sans-serif;
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f4f8 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    min-height: 100vh;
    position: relative;
}

/* Welcome Page Styles */
.welcome-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 1rem;
}

.welcome-image-container {
    position: relative;
    max-width: 50vw;
    max-height: 90vh;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-medium);
}

.welcome-image {
    width: 100%;
    height: auto;
    display: block;
}

.welcome-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 3rem 2rem 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.start-btn {
    background: var(--gradient-primary);
    border: none;
    color: white;
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.start-btn:hover {
    box-shadow: 0 20px 40px rgba(47, 50, 146, 0.3);
    color: white;
}

/* Fixed focus states for start button - moved to end */

.start-btn:active {
    transform: translateY(-1px);
}

.start-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.start-btn:hover::before {
    left: 100%;
}

/* Main Page Styles */
.main-page {
    min-height: 100vh;
    padding-top: 2rem;
    display: none;
}

.main-page .container {
    max-width: 1400px;
    padding-left: 1rem;
    padding-right: 1rem;
}

.header-banner-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.header-banner {
    max-width: 800px;
    width: auto;
    height: 80px;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
}

.app-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    padding: 2rem;
    margin-bottom: 2rem;
    border: none;
    position: relative;
    overflow: hidden;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.app-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
}

/* Step Indicators */
.step-indicator {
    display: flex;
    justify-content: center;
    margin-bottom: 3rem;
}

.step {
    display: flex;
    align-items: center;
    margin: 0 1rem;
}

.step-circle {
    width: 50px;
    height: 50px;
    border-radius: 30%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 3px solid var(--lighter-blue);
    background: white;
    color: var(--light-blue);
    transition: all 0.3s ease;
}

.step-circle.active {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--primary-blue);
    transform: scale(1.1);
}

.step-circle.completed {
    background: var(--light-blue);
    color: white;
    border-color: var(--light-blue);
}

.step-line {
    width: 100px;
    height: 3px;
    background: var(--lighter-blue);
    margin: 0 1rem;
}

.step-line.completed {
    background: var(--light-blue);
}

/* Form Styles */
.form-group {
    margin-bottom: 2rem;
}

.form-label {
    color: var(--primary-blue);
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.form-control {
    border: 2px solid var(--lighter-blue);
    border-radius: 16px;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
}

.form-control:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 0.25rem rgba(47, 50, 146, 0.1);
    background: white;
}

.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    border: 3px dashed var(--lighter-blue);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--gradient-secondary);
    cursor: pointer;
}

.file-upload-wrapper:hover {
    border-color: var(--primary-blue);
    transform: translateY(-2px);
}

.file-upload-wrapper.has-file {
    border-color: var(--light-blue);
    background: rgba(123, 170, 218, 0.1);
}

.file-upload-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.file-upload-icon {
    font-size: 3rem;
    color: var(--light-blue);
    margin-bottom: 1rem;
}

.file-upload-text {
    color: var(--primary-blue);
    font-size: 1.25rem;
    font-weight: 500;
}

.file-upload-hint {
    color: var(--light-blue);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Editor Styles */
.editor-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-soft);
    max-width: 600px;
    margin: 0 auto;
    height: fit-content;
}

.editor-viewport {
    position: relative;
    width: 100%;
    max-width: 450px;
    height: 450px;
    margin: 0 auto;
    border: 4px solid var(--light-blue);
    border-radius: 20px;
    overflow: hidden;
    background: var(--gradient-secondary);
    transform: translateZ(0);
    backface-visibility: hidden;
    box-shadow: var(--shadow-medium);
}

.image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    will-change: background-size, background-position;
    backface-visibility: hidden;
}

.frame-overlay {
    position: absolute;
    top: -4px;
    left: -4px;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 2;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Control Panel */
.control-panel {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: 2rem;
    max-width: 450px;
    height: fit-content;
    align-self: flex-start;
}

.control-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--lighter-blue);
}

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.control-title {
    color: var(--primary-blue);
    font-weight: 600;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.direction-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 200px;
    margin: 0 auto;
}

.control-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 16px;
    background: var(--gradient-secondary);
    color: var(--primary-blue);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(47, 50, 146, 0.1);
    touch-action: manipulation;
}

.control-btn:hover {
    background: var(--gradient-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

/* Fixed focus states for control buttons - moved to end */

.control-btn:active {
    transform: translateY(0);
}

.control-btn.reset {
    background: var(--red-accent);
    color: white;
    font-size: 1rem;
}

.control-btn.reset:hover {
    background: #a02d35;
    color: white;
}

/* Fixed focus states for reset button - moved to end */

.scale-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.scale-display {
    background: var(--gradient-secondary);
    border: 2px solid var(--lighter-blue);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 700;
    color: var(--primary-blue);
    min-width: 100px;
    text-align: center;
    font-size: 1.1rem;
}

/* Action Buttons */
.action-btn {
    padding: 1rem 2rem;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.btn-primary-custom {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-soft);
}

.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    color: white;
}

/* Fixed focus states for primary button - moved to end */

.btn-accent {
    background: var(--red-accent);
    color: white;
    box-shadow: var(--shadow-soft);
}

.btn-accent:hover {
    background: #a02d35;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    color: white;
}

/* Fixed focus states for accent button (Download) - moved to end */

.btn-secondary-custom {
    background: white;
    color: var(--primary-blue);
    border: 2px solid var(--lighter-blue);
}

.btn-secondary-custom:hover {
    background: var(--lighter-blue);
    border-color: var(--light-blue);
    transform: translateY(-1px);
    color: var(--primary-blue);
}

/* Fixed focus states for secondary button - moved to end */

/* Override Bootstrap default focus styles for all custom buttons */
.btn:focus,
.btn:focus-visible {
    box-shadow: none !important;
}

/* Disable browser default button styles */
button:focus,
button:focus-visible,
.btn:focus,
.btn:focus-visible {
    outline: none !important;
    background-color: transparent !important;
}

/* Re-apply custom shadows and styles for buttons that need them */
.start-btn:focus,
.start-btn:focus-visible {
    outline: 3px solid rgba(47, 50, 146, 0.5) !important;
    outline-offset: 2px !important;
    box-shadow: 0 20px 40px rgba(47, 50, 146, 0.3) !important;
    background: var(--gradient-primary) !important;
    color: white !important;
}

.control-btn:focus, 
.control-btn:focus-visible {
    outline: 3px solid rgba(47, 50, 146, 0.5) !important;
    outline-offset: 2px !important;
    box-shadow: var(--shadow-soft) !important;
    background: var(--gradient-primary) !important;
    color: white !important;
}

.control-btn.reset:focus,
.control-btn.reset:focus-visible {
    outline: 3px solid rgba(191, 56, 65, 0.5) !important;
    outline-offset: 2px !important;
    background: #a02d35 !important;
    color: white !important;
}

.btn-primary-custom:focus,
.btn-primary-custom:focus-visible,
.action-btn.btn-primary-custom:focus,
.action-btn.btn-primary-custom:focus-visible {
    outline: 3px solid rgba(47, 50, 146, 0.5) !important;
    outline-offset: 2px !important;
    box-shadow: var(--shadow-medium) !important;
    background: var(--gradient-primary) !important;
    color: white !important;
}

.btn-accent:focus,
.btn-accent:focus-visible,
.action-btn.btn-accent:focus,
.action-btn.btn-accent:focus-visible {
    outline: 3px solid rgba(191, 56, 65, 0.5) !important;
    outline-offset: 2px !important;
    box-shadow: var(--shadow-medium) !important;
    background: #a02d35 !important;
    color: white !important;
}

.btn-secondary-custom:focus,
.btn-secondary-custom:focus-visible,
.action-btn.btn-secondary-custom:focus,
.action-btn.btn-secondary-custom:focus-visible {
    outline: 3px solid rgba(47, 50, 146, 0.5) !important;
    outline-offset: 2px !important;
    background: var(--lighter-blue) !important;
    border-color: var(--light-blue) !important;
    color: var(--primary-blue) !important;
}

/* Loading States */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--lighter-blue);
    border-top: 4px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--primary-blue);
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

.loading-subtext {
    color: var(--light-blue);
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* Frame Loading Indicator */
.frame-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 1rem;
    display: none;
    align-items: center;
    gap: 0.75rem;
    z-index: 3;
    box-shadow: var(--shadow-soft);
}

.frame-loading.active {
    display: flex;
}

.frame-loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--lighter-blue);
    border-top: 2px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.6s ease-out;
}

.slide-up {
    animation: slideUp 0.6s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Responsive Design */
@media (max-width: 768px) {
    .welcome-image-container {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .welcome-overlay {
        padding: 2rem 1rem 1.5rem;
    }
    
    .start-btn {
        padding: 0.75rem 2rem;
        font-size: 1.1rem;
    }
    
    .header-banner-container {
        padding: 0 1rem;
        margin-bottom: 1rem;
    }
    
    .header-banner {
        height: 60px;
        max-width: 600px;
    }

    .main-page {
        padding-top: 1rem;
    }
    
    .main-page .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .app-card {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .editor-viewport {
        max-width: 350px;
        height: 350px;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.1rem;
    }
    
    .step-indicator {
        margin-bottom: 2rem;
    }
    
    .step {
        margin: 0 0.5rem;
    }
    
    .step-circle {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }
    
    .step-line {
        width: 60px;
    }
}

@media (max-width: 576px) {
    .welcome-page {
        min-height: 70vh;
    }

    .welcome-overlay {
        padding: 1.5rem 1rem 1rem;
    }
    
    .start-btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    .header-banner-container {
        padding: 0 1.5rem;
        margin-bottom: 1rem;
    }
    
    .header-banner {
        height: 50px;
        max-width: 350px;
    }
    
    .control-panel {
        padding: 1.5rem;
        margin: 1rem 0 3rem 0;
    }
    
    .editor-container {
        margin-bottom: 1.5rem;
        position: sticky;
        top: 10px;
    }
    
    .editor-viewport {
        max-width: 280px;
        height: 280px;
        margin: 0 auto 1rem;
    }
    
    .direction-controls {
        max-width: 150px;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
}

/* Control panel alignment for medium screens */
@media (min-width: 425px) and (max-width: 992px) {
    .control-panel {
        max-width: 600px;
        margin: 2rem auto 1rem auto;
        align-self: auto;
    }
}

/* Mobile layout improvements */
@media (max-width: 425px) {
    #editor-step .row {
        flex-direction: column;
    }
    
    .editor-container {
        position: sticky;
        top: 10px;
        z-index: 100;
        margin-bottom: 1rem;
        background: white;
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-medium);
    }
    
    .control-panel {
        position: relative;
        margin-top: 0;
        margin-bottom: 2rem;
        max-height: calc(100vh - 400px);
        overflow-y: auto;
    }
    
    /* Ensure smooth scrolling for controls */
    .control-panel::-webkit-scrollbar {
        width: 6px;
    }
    
    .control-panel::-webkit-scrollbar-track {
        background: var(--lighter-blue);
        border-radius: 3px;
    }
    
    .control-panel::-webkit-scrollbar-thumb {
        background: var(--light-blue);
        border-radius: 3px;
    }
    
    .control-panel::-webkit-scrollbar-thumb:hover {
        background: var(--primary-blue);
    }
}