@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

:root {
    --sphene-gold: #D4AF37;
    --crystal-blue: #4A90E2;
    --deep-crystal: #2C5282;
    --ethereal-purple: #8B5CF6;
    --network-active: #10B981;
    --background-dark: #0F1419;
    --background-card: #1A202C;
    --text-primary: #F7FAFC;
    --text-secondary: #A0AEC0;
    --border-color: #2D3748;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Crimson Text', serif;
    background: linear-gradient(135deg, var(--background-dark) 0%, #1a1a2e 50%, var(--deep-crystal) 100%);
    color: var(--text-primary);
    overflow: hidden;
    min-width: 786px;
    min-height: 639px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 23, 0.85);
    z-index: -1;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.header-section {
     background: var(--background-dark);
     border-bottom: 2px solid var(--sphene-gold);
     padding: 20px;
     flex-shrink: 0;
 }
 
 .header-content {
     max-width: 1200px;
     margin: 0 auto;
     display: flex;
     align-items: center;
     gap: 20px;
 }
 
 .back-button {
     display: inline-flex;
     align-items: center;
     gap: 8px;
     color: var(--text-secondary);
     text-decoration: none;
     padding: 8px 16px;
     border-radius: 6px;
     transition: all 0.3s ease;
     font-size: 0.9rem;
     border: 1px solid var(--border-color);
     background: rgba(212, 175, 55, 0.05);
     flex-shrink: 0;
 }
 
 .back-button:hover {
     color: var(--sphene-gold);
     background: rgba(212, 175, 55, 0.1);
     border-color: var(--sphene-gold);
     transform: translateX(-2px);
     box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
 }
 
 .back-arrow {
     font-size: 1.2rem;
     font-weight: bold;
     transition: transform 0.3s ease;
 }
 
 .back-button:hover .back-arrow {
     transform: translateX(-3px);
 }

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.header-text h1 {
    font-family: 'Cinzel', serif;
    color: var(--sphene-gold);
    font-size: 1.8rem;
    margin: 0;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.header-text p {
    color: var(--text-secondary);
    margin: 5px 0 0 0;
    font-size: 1rem;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background-card);
    min-height: 0; /* Allows proper flex shrinking */
    overflow: hidden; /* Prevent content overflow */
    border-radius: 12px;
    margin: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.toolbar {
    background: var(--background-dark);
    padding: 15px;
    border-bottom: 2px solid var(--sphene-gold);
    display: flex;
    gap: 15px;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.language-selector {
    margin-left: auto;
    position: relative;
}

.custom-dropdown {
    position: relative;
    width: 120px;
}

.dropdown-selected {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid var(--sphene-gold);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    transition: all 0.3s ease;
}

.dropdown-selected:hover {
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.flag-icon {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
}

.dropdown-arrow {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.2s ease;
}

.custom-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(42, 42, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    margin-top: 4px;
    z-index: 1000;
    display: none;
    backdrop-filter: blur(10px);
}

.custom-dropdown.open .dropdown-options {
    display: block;
}

.dropdown-option {
    padding: 8px 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.dropdown-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-option:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-option:last-child {
    border-radius: 0 0 8px 8px;
}

.btn {
    background: linear-gradient(135deg, var(--sphene-gold), #B8941F);
    color: var(--background-dark);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.btn:hover {
    background: linear-gradient(135deg, #E6C547, var(--sphene-gold));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    min-height: 0; /* Allow proper flex shrinking */
    overflow: hidden; /* Prevent content overflow */
}

.canvas-container::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: rgba(212, 175, 55, 0.02);
    pointer-events: none;
    z-index: 1;
    transition: all 0.3s ease;
}

.canvas-container.has-image::before {
    display: none;
}

.canvas-container::after {
    content: '📁 Drag & Drop Image Here\A or click "Load Image" button';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 16px;
    text-align: center;
    white-space: pre-line;
    pointer-events: none;
    z-index: 2;
    opacity: 0.7;
    font-weight: 500;
}

.canvas-container.has-image::after {
    display: none;
}

#imageCanvas {
    border: 2px solid var(--sphene-gold);
    background: var(--background-dark);
    cursor: crosshair;
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.2);
}

.sidebar {
    width: 320px;
    background: var(--background-dark);
    border-left: 2px solid var(--sphene-gold);
    display: flex;
    flex-direction: column;
    border-radius: 0 12px 12px 0;
    overflow-y: auto;
    max-height: calc(100vh - 120px); /* Account for header height */
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--sphene-gold) var(--background-dark);
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--background-dark);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--sphene-gold);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #E6C547;
}

/* Responsive adjustments for smaller screens */
@media (max-height: 800px) {
    .sidebar {
        max-height: calc(100vh - 100px);
    }
}

@media (max-height: 600px) {
    .sidebar {
        max-height: calc(100vh - 80px);
    }
    
    .info-panel {
        padding: 10px;
    }
    
    .quality-panel {
        padding: 10px;
    }
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 300px;
        border-left: none;
        border-top: 2px solid var(--sphene-gold);
        border-radius: 0 0 12px 12px;
    }
}

.info-panel {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 5px;
    background: rgba(212, 175, 55, 0.05);
}

.info-panel.collapsed {
    padding-bottom: 0;
}

.info-panel.collapsed .info-item {
    display: none;
}

.info-title {
    font-weight: bold;
    margin-bottom: 10px;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-title::after {
    content: '▼';
    font-size: 10px;
    transition: transform 0.3s ease;
}

.info-panel.collapsed .info-title::after {
    transform: rotate(-90deg);
}

.info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 12px;
    color: #cccccc;
}

.quality-panel {
    padding: 15px;
    flex: 1;
    min-height: 0;
}

.quality-title {
    font-weight: bold;
    margin-bottom: 15px;
    color: #ffffff;
}

.slider-group {
    margin-bottom: 8px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 12px;
    color: #cccccc;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--sphene-gold);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.7);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--sphene-gold);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.preview-section {
    margin-top: 20px;
    text-align: center;
}

.preview-title {
    font-size: 12px;
    color: #cccccc;
    margin-bottom: 10px;
}

#previewCanvas {
    border: 1px solid var(--sphene-gold);
    background: var(--background-dark);
    border-radius: 4px;
}

.preview-info {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.status-bar {
    background: var(--background-dark);
    padding: 8px 15px;
    border-top: 2px solid var(--sphene-gold);
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0; /* Prevent shrinking */
    z-index: 100;
    border-radius: 0 0 12px 0;
}

.stats-counter {
    background: var(--background-dark);
    padding: 10px 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Prevent shrinking */
    position: relative;
    z-index: 101;
    border-radius: 0 0 0 12px;
}

.counter-label {
    font-size: 12px;
    color: #cccccc;
    font-weight: 500;
}

.counter-value {
    font-size: 16px;
    font-weight: bold;
    color: var(--sphene-gold);
    transition: all 0.2s ease;
    min-width: 30px;
    text-align: right;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.file-input {
    display: none;
}

.selection-overlay {
    position: absolute;
    border: 2px solid var(--sphene-gold);
    background: rgba(212, 175, 55, 0.1);
    pointer-events: none;
    display: none;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(212, 175, 55, 0.15);
    border: 3px dashed var(--sphene-gold);
    border-radius: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--sphene-gold);
    font-weight: 700;
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.8);
    z-index: 10;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
        border-color: var(--sphene-gold);
    }
    50% {
        box-shadow: 0 0 30px rgba(212, 175, 55, 0.6);
        border-color: #E6C547;
    }
}