@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* Color System */
    --bg-primary: #0F0F23;
    --bg-secondary: #1A1A2E;
    --bg-tertiary: #16213E;
    --surface: rgba(255, 255, 255, 0.03);
    --surface-elevated: rgba(255, 255, 255, 0.08);
    --surface-hover: rgba(255, 255, 255, 0.12);
    
    /* Accent Colors */
    --accent-primary: #6366F1;
    --accent-secondary: #8B5CF6;
    --accent-success: #10B981;
    --accent-warning: #F59E0B;
    --accent-danger: #EF4444;
    --accent-info: #06B6D4;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%);
    --gradient-secondary: linear-gradient(135deg, #0EA5E9 0%, #06B6D4 50%, #10B981 100%);
    --gradient-danger: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    --gradient-success: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --gradient-warning: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    
    /* Text Colors */
    --text-primary: #FFFFFF;
    --text-secondary: #A1A1AA;
    --text-muted: #71717A;
    --text-inverse: #000000;
    
    /* Border & Shadow */
    --border-primary: rgba(255, 255, 255, 0.1);
    --border-secondary: rgba(255, 255, 255, 0.05);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    
    /* Border Radius */
    --radius-xs: 0.25rem;
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;
    --radius-full: 9999px;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    
    /* Animation */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

*::before,
*::after {
    box-sizing: inherit;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 25% 25%, #6366F150 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, #8B5CF650 0%, transparent 50%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    font-weight: 400;
    padding: var(--space-lg);
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideUp 0.8s ease-out;
}

.header {
    background: var(--gradient-primary);
    padding: var(--space-2xl) var(--space-xl);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.3;
}

.header h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    color: white;
    margin-bottom: var(--space-sm);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.header p {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    position: relative;
    z-index: 1;
}

.main-content {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: var(--space-2xl);
    padding: var(--space-2xl);
    min-height: 600px;
}

.controls-panel {
    background: var(--surface-elevated);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-lg);
    height: fit-content;
    position: sticky;
    top: var(--space-lg);
}

.control-group {
    margin-bottom: var(--space-xl);
}

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

.control-group h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-secondary);
}

.file-input-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: var(--space-md);
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-lg) var(--space-xl);
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.file-input-label::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.6s;
}

.file-input-label:hover::before {
    left: 100%;
}

.file-input-label:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.slider-container {
    margin: var(--space-lg) 0;
}

.slider-container label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

.slider-value {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 0.8rem;
    background: rgba(99, 102, 241, 0.1);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-xs);
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: var(--radius-xs);
    background: var(--surface);
    outline: none;
    -webkit-appearance: none;
    transition: all var(--transition-normal);
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gradient-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    border: 2px solid white;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg), 0 0 15px rgba(99, 102, 241, 0.5);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gradient-primary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.input-field, .textarea-field {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    transition: all var(--transition-normal);
    margin-bottom: var(--space-md);
}

.input-field:focus, .textarea-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--surface-hover);
}

.textarea-field {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    font-family: inherit;
    letter-spacing: 0.025em;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.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;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--gradient-danger);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 15px rgba(239, 68, 68, 0.4);
}

.btn-secondary {
    background: var(--gradient-success);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 15px rgba(16, 185, 129, 0.4);
}

.btn-accent {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-small {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
}

.canvas-container {
    background: var(--surface-elevated);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 600px;
    border: 2px dashed var(--border-primary);
    border-radius: var(--radius-lg);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    overflow: hidden;
}

.canvas-wrapper.has-image {
    border-color: var(--accent-primary);
    background: transparent;
    box-shadow: inset 0 0 50px rgba(99, 102, 241, 0.1);
}

.placeholder-text {
    color: var(--text-primary);
    font-size: 1.25rem;
    text-align: center;
    pointer-events: none;
    font-weight: 500;
}

#photoCanvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
}

.overlay-element {
    position: absolute;
    cursor: move;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
    user-select: none;
}

.overlay-element:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    transform: scale(1.02);
}

.overlay-element.selected {
    border-color: var(--accent-danger);
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.4);
    transform: scale(1.05);
}

.overlay-element.dragging {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.5);
    transform: scale(1.08);
    z-index: 1000;
}

.text-overlay {
    backdrop-filter: blur(10px);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    font-weight: 600;
}

.tabs {
    display: flex;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 4px;
    margin-bottom: var(--space-xl);
    border: 1px solid var(--border-secondary);
    gap: 4px;
}

.tab {
    flex: 1;
    padding: 12px 16px;
    text-align: center;
    cursor: pointer;
    border-radius: 10px;
    transition: all var(--transition-normal);
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    min-height: 44px;
}

.tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-normal);
    border-radius: 10px;
}

.tab.active::before {
    opacity: 1;
}

.tab.active {
    color: white;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transform: none;
}

.tab:hover:not(.active) {
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.tab span {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.elements-list {
    max-height: 300px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    margin-top: var(--space-md);
}

.element-item {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.element-item:last-child {
    border-bottom: none;
}

.element-item:hover {
    background: var(--surface-hover);
}

.element-item.selected {
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid var(--accent-primary);
}

.element-info {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.element-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

.element-info small {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.element-controls {
    display: flex;
    gap: var(--space-sm);
}

.color-input {
    width: 40px;
    height: 32px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    overflow: hidden;
    background: transparent;
}

.position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.download-section {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: var(--space-2xl);
    padding-top: var(--space-2xl);
    border-top: 1px solid var(--border-secondary);
}

.download-section .btn {
    padding: var(--space-lg) var(--space-2xl);
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    margin: var(--space-md) 0;
    backdrop-filter: blur(10px);
}

.status-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }
    
    .controls-panel {
        position: static;
    }
}

@media (max-width: 768px) {
    body {
        padding: var(--space-md);
    }
    
    .header {
        padding: var(--space-xl) var(--space-lg);
    }
    
    .main-content {
        padding: var(--space-xl);
        gap: var(--space-lg);
    }
    
    .controls-panel {
        padding: var(--space-lg);
    }
    
    .canvas-container {
        padding: var(--space-lg);
    }
    
    .position-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .canvas-wrapper {
        height: 400px;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: var(--radius-xs);
}

::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: var(--radius-xs);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-secondary);
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }
}

.pulse {
    animation: pulse 1s ease-in-out;
}

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

/* Loading States */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Focus States */
.btn:focus-visible,
.tab:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.input-field:focus-visible,
.textarea-field:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}