:root {
    --bg-color: #1a1a1a;
    --sidebar-bg: #252525;
    --text-color: #ffffff;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --border-color: #404040;
    --input-bg: #333333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar Styles */
.sidebar {
    width: 300px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    flex-shrink: 0;
    overflow-y: auto;
}

.logo {
    margin-bottom: 2rem;
    text-align: center;
}

.logo h2 {
    font-weight: 600;
    color: var(--accent-color);
}

/* Presets Section - Removed old styles as they are now in accordion */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
}

.preset-btn {
    padding: 0.8rem 0.5rem;
    background-color: #333;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    text-align: center;
}

.preset-btn:hover {
    background-color: #404040;
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.preset-btn:active {
    transform: translateY(0);
}

/* Face Tools - Removed old styles as they are now in accordion */
#face-overlays {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through */
}

.face-box {
    position: absolute;
    /* Removed default border to avoid boxy look on effects */
    /* border: 2px solid rgba(255, 255, 255, 0.5); */
    /* box-shadow: 0 0 5px rgba(0,0,0,0.5); */
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.face-blur {
    backdrop-filter: blur(15px); /* Increased blur */
    -webkit-backdrop-filter: blur(15px);
    border-radius: 12px;
    /* Ensure no border is visible */
    border: none;
    box-shadow: none;
}

.face-emoji {
    font-size: 2rem;
    border: none;
    box-shadow: none;
    text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.face-enhance {
    backdrop-filter: brightness(1.1) contrast(1.1) saturate(1.1);
    -webkit-backdrop-filter: brightness(1.1) contrast(1.1) saturate(1.1);
    border: none;
    box-shadow: inset 0 0 20px rgba(255,255,255,0.2);
    border-radius: 12px; /* Rounded rectangle */
}

.controls {
    /* Removed flex: 1 to allow accordion to take space */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 10px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* Actions Area */
.actions {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    flex-shrink: 0;
    background-color: var(--sidebar-bg);
}

.btn {
    padding: 0.9rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-align: center;
    font-size: 0.9rem;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.primary {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    color: white;
}

.primary:hover {
    filter: brightness(1.1);
}

.secondary {
    background-color: #333;
    color: white;
    border: 1px solid #444;
}

.secondary:hover {
    background-color: #404040;
    border-color: #555;
}

.success {
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
    color: white;
}

.success:hover:not(:disabled) {
    filter: brightness(1.1);
}

.upload-label {
    display: block;
    cursor: pointer;
    background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
    margin-bottom: 1rem;
}

.upload-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px;
    border-radius: 20px;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.zoom-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.2s;
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.zoom-level {
    color: white;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    min-width: 50px;
    justify-content: center;
}

/* Text Overlay Item */
.text-overlay-item {
    position: absolute;
    cursor: move;
    user-select: none;
    padding: 4px;
    border: 1px dashed transparent;
    min-width: 20px;
    min-height: 20px;
    pointer-events: auto;
}

.text-overlay-item:hover, .text-overlay-item.selected {
    border-color: #fff;
    background: rgba(0, 0, 0, 0.1);
}

.text-delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: red;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    border: 2px solid white;
}

.text-overlay-item:hover .text-delete-btn,
.text-overlay-item.selected .text-delete-btn {
    display: flex;
}

/* Main Image Area */
.image-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-color: var(--bg-color);
    position: relative;
    overflow: hidden; /* Ensure zoomed image doesn't overflow */
}

.image-area.highlight {
    border: 2px dashed var(--accent-color);
    background-color: rgba(255, 255, 255, 0.05);
}

.image-container {
    max-width: 100%;
    max-height: calc(100% - 100px); /* Subtract gallery height */
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#preview-img {
    display: none;
}

/* Compare Slider Styles */
.compare-container {
    position: relative;
    max-width: 100%;
    max-height: 80vh;
    overflow: hidden;
    user-select: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

#edited-img {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    width: auto;
    height: auto;
}

#original-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
    border-right: 2px solid white;
    background-color: var(--bg-color); /* Prevent transparency issues */
}

#original-img {
    display: block;
    max-width: none; /* Important: allow it to be full size */
    height: 100%;
    /* Width will be set by JS to match edited-img */
}

.slider-label {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    pointer-events: none;
}

#slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%; /* Matches overlay width */
    width: 40px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: ew-resize;
}

.handle-line {
    width: 2px;
    height: 100%;
    background: white;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.handle-circle {
    position: absolute;
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color);
    font-weight: bold;
    font-size: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.placeholder-text {
    text-align: center;
    color: #666;
}

.placeholder-text p {
    font-size: 1.2rem;
    font-weight: 500;
}

.placeholder-text .sub-text {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    opacity: 0.7;
}

/* Tool Selector */
.tool-selector {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    justify-content: center;
    background: rgba(0,0,0,0.2);
    padding: 0.5rem;
    border-radius: 8px;
}

.tool-btn {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #333;
    border: 1px solid #444;
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.tool-btn:hover {
    background-color: #404040;
    transform: translateY(-2px);
}

.tool-btn.active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.tool-panel {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
    margin-top: 1rem;
}

.tool-panel.active {
    display: block !important;
}

/* Shape Buttons */
.shape-btn {
    padding: 8px;
    border: 2px solid var(--border-color);
    background: var(--sidebar-bg);
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.shape-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.shape-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.control-group {
    margin-bottom: 1.2rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #ccc;
}

/* Accordion Styles */
.accordion-item {
    border-bottom: 1px solid var(--border-color);
}

.accordion-header {
    padding: 1rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.accordion-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.accordion-icon {
    transition: transform 0.3s;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
    color: var(--accent-color);
}

.accordion-content {
    display: none;
    padding-bottom: 1.5rem;
    animation: slideDown 0.3s ease-out;
}

.accordion-item.active .accordion-content {
    display: block;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Download Group */
.download-group {
    display: flex;
    gap: 0.5rem;
}

.format-select {
    background-color: #333;
    color: var(--text-color);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 0 1rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.format-select:focus {
    border-color: var(--accent-color);
}

#download-btn {
    flex: 1;
}

/* Adjust controls within accordion */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Gallery Strip */
.gallery-strip {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.8rem;
    overflow-x: auto;
    z-index: 20;
    border-top: 1px solid var(--border-color);
}

.gallery-strip::-webkit-scrollbar {
    height: 6px;
}

.gallery-strip::-webkit-scrollbar-track {
    background: transparent;
}

.gallery-strip::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 3px;
}

.gallery-item {
    width: 70px;
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    flex-shrink: 0;
    position: relative;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item.active {
    border-color: var(--accent-color);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.gallery-item:hover {
    transform: translateY(-2px);
}

.gallery-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.7);
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

.gallery-item:hover .gallery-remove {
    opacity: 1;
}

/* Toggle Switch for Resize */
.toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 1rem;
}

.toggle-label {
    font-weight: 500;
    color: var(--text-color);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555; /* Lighter grey for better visibility */
    transition: .4s;
    border-radius: 24px;
    border: 2px solid #888; /* Thicker, brighter border */
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3); /* Inner shadow for depth */
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 2px;
    background-color: #bbb; /* Lighter toggle circle when OFF */
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); /* Shadow for the circle */
}

input:checked + .slider {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4); /* Glow effect when ON */
}

input:checked + .slider:before {
    transform: translateX(20px);
    background-color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); /* Stronger shadow when ON */
}

/* Resize Controls Container */
#resize-controls {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.resize-inputs {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.input-wrapper label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.number-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    color: var(--text-color);
    font-family: inherit;
}

.number-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.aspect-lock {
    padding-bottom: 0.6rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    font-size: 1.2rem;
}

.aspect-lock.active {
    opacity: 1;
}

.info-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: center;
}

/* Zoom Panel in Sidebar */
.zoom-panel {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.zoom-panel label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    color: var(--text-color);
    font-weight: 500;
}

.zoom-panel input[type="range"] {
    width: 100%;
    cursor: pointer;
    margin-top: 5px;
}

/* Text Content Reset */
.text-content p {
    margin: 0;
    padding: 0;
}

.text-content {
    line-height: 1.2;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        overflow-y: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .image-area {
        min-height: 50vh;
    }
}

/* Zoom Hint Styles */
#zoom-hint {
    animation: fadeInUp 0.3s ease-out;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

#zoom-hint strong {
    color: #4fc3f7;
    font-weight: 600;
}
