/* CSS Custom Properties for Blue/White Theme */

:root {
    --primary-blue: #2563eb;
    --primary-blue-dark: #1d4ed8;
    --primary-blue-light: #3b82f6;
    --secondary-blue: #dbeafe;
    --accent-blue: #60a5fa;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --border-radius: 0.5rem;
    --border-radius-sm: 0.25rem;
    --border-radius-lg: 0.75rem;
    --border-radius-xl: 1rem;
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
}


/* Reset and Base Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--secondary-blue) 100%);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}


/* Header Styles */

.header {
    background: var(--white);
    box-shadow: var(--shadow);
    padding: 1rem 0;
    position: relative;
    z-index: 100;
    border-bottom: 2px solid var(--secondary-blue);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-blue);
    text-decoration: none;
    transition: var(--transition-fast);
}

.logo:hover {
    color: var(--primary-blue-dark);
    transform: translateY(-1px);
}

.logo i {
    font-size: 1.75rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    min-height: 2.5rem;
    position: relative;
    overflow: hidden;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--primary-blue);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-blue-dark);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--white);
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary-blue);
    color: var(--white);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}

.btn-outline:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}


/* Editor Container */

.editor-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}


/* Editor Header */

.editor-header {
    background: var(--white);
    box-shadow: var(--shadow);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--secondary-blue);
    flex-wrap: wrap;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-blue);
    margin: 0;
}


/* Editor Main */

.editor-main {
    flex: 1;
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: calc(100vh - 80px);
}


/* Responsive Grid */

@media (max-width: 968px) {
    .editor-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .editor-sidebar {
        order: 1;
    }
    .canvas-area {
        order: 2;
    }
}


/* Editor Sidebar */

.editor-sidebar {
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
}

@media (max-width: 968px) {
    .editor-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
        max-height: none;
        padding: 1rem;
    }
}

.upload-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
}

.upload-area {
    border: 3px dashed var(--gray-300);
    border-radius: var(--border-radius-lg);
    background: var(--white);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2rem;
}

@media (max-width: 480px) {
    .upload-area {
        padding: 1.5rem 0.75rem;
    }
}

.upload-area:hover {
    border-color: var(--primary-blue);
    background: var(--secondary-blue);
}

.upload-area.dragover {
    border-color: var(--primary-blue);
    background: var(--secondary-blue);
    transform: scale(1.02);
}

.upload-content svg {
    color: var(--primary-blue);
    margin-bottom: 1rem;
}

.upload-content p {
    color: var(--gray-600);
    font-size: 0.95rem;
}


/* Tools Section */

.tools-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
}

.tool-panel {
    margin-bottom: 1rem;
}

.tool-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    background: var(--white);
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
}

.tool-btn:hover:not(:disabled) {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    background: var(--secondary-blue);
}

.tool-btn.active {
    border-color: var(--primary-blue);
    background: var(--primary-blue);
    color: var(--white);
    box-shadow: var(--shadow);
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tool-controls {
    display: none;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-top: 0.5rem;
    animation: slideDown 0.3s ease;
}


/* Canvas Area - IMPROVED RESPONSIVE DESIGN */

.canvas-area {
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 1rem;
    min-height: calc(100vh - 160px);
}

@media (max-width: 968px) {
    .canvas-area {
        min-height: calc(100vh - 200px);
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .canvas-area {
        min-height: calc(100vh - 180px);
        padding: 0.5rem;
    }
}

.canvas-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    text-align: center;
    padding: 3rem 2rem;
}

@media (max-width: 480px) {
    .canvas-placeholder {
        padding: 2rem 1rem;
    }
}

.canvas-placeholder svg {
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.canvas-placeholder p {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--gray-600);
}


/* IMPROVED CANVAS WRAPPER */

#canvas-wrapper {
    position: relative;
    display: none;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
}

#canvas-wrapper.show {
    display: flex;
}


/* IMPROVED CANVAS STYLING */

#main-canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    background: var(--white);
    object-fit: contain;
    display: block;
}


/* Ensure canvas is responsive on all devices */

@media (max-width: 768px) {
    #main-canvas {
        max-width: calc(100vw - 2rem);
        max-height: calc(100vh - 200px);
    }
}

@media (max-width: 480px) {
    #main-canvas {
        max-width: calc(100vw - 1rem);
        max-height: calc(100vh - 180px);
    }
}


/* Control Styles */

.control-row {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.control-row:last-child {
    margin-bottom: 0;
}

.control-row label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    min-width: 80px;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .control-row label {
        min-width: 60px;
        font-size: 0.8rem;
    }
}

.input-field,
.color-picker {
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    transition: var(--transition);
    flex: 1;
    min-width: 0;
}

.input-field:focus,
.color-picker:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px var(--secondary-blue);
}

.slider {
    flex: 1;
    height: 0.25rem;
    border-radius: var(--border-radius);
    background: var(--gray-200);
    outline: none;
    min-width: 100px;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.slider::-webkit-slider-thumb:hover {
    background: var(--primary-blue-dark);
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: var(--shadow);
}

.style-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    background: var(--white);
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
    font-weight: bold;
    min-width: 2.5rem;
}

.style-btn:hover {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.style-btn.active {
    background: var(--primary-blue);
    color: var(--white);
    border-color: var(--primary-blue);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    min-height: auto;
}


/* TEXT ELEMENT STYLES */

.text-element {
    position: absolute;
    cursor: move;
    user-select: none;
    z-index: 10;
    padding: 4px 8px;
    border: 2px solid transparent;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    transition: var(--transition-fast);
    min-width: 50px;
    min-height: 25px;
    word-wrap: break-word;
    white-space: nowrap;
    overflow: visible;
}

.text-element:hover {
    border-color: var(--primary-blue);
    background: rgba(255, 255, 255, 0.2);
}

.text-element.selected {
    border-color: var(--primary-blue);
    background: rgba(37, 99, 235, 0.1);
    box-shadow: 0 0 0 2px var(--secondary-blue);
}

.text-element.dragging {
    cursor: grabbing;
    z-index: 1000;
    transform: scale(1.05);
}

.text-element:focus {
    outline: none;
    cursor: text;
}


/* ANIMATION KEYFRAMES */

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}


/* MOBILE RESPONSIVE ADJUSTMENTS */

@media (max-width: 768px) {
    .header-left h1 {
        font-size: 1rem;
    }
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-height: 2.25rem;
    }
    .tool-btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }
    .tool-controls {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .editor-header {
        padding: 0.75rem 1rem;
    }
    .header-left {
        gap: 0.5rem;
    }
    .header-left h1 {
        font-size: 0.9rem;
    }
    .btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
        min-height: 2rem;
        gap: 0.25rem;
    }
    .btn svg {
        width: 16px;
        height: 16px;
    }
}


/* UTILITY CLASSES */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.loading {
    opacity: 0.5;
    pointer-events: none;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}


/* HIGH DPI DISPLAY SUPPORT */

@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    #main-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
