﻿:root {
    /* Cute/Pastel Theme */
    --primary-color: #FF8FAB;
    /* Coral Pink */
    --primary-hover: #FF7496;
    --secondary-color: #4ECDC4;
    /* Mint/Teal */
    --secondary-hover: #36B9B0;
    --success-color: #A8E6CF;
    /* Pastel Green */
    --success-hover: #8BD3B8;

    --bg-gradient-start: #FF9A9E;
    --bg-gradient-end: #FECFEF;

    --surface-color: rgba(255, 255, 255, 0.7);
    --surface-border: rgba(255, 255, 255, 0.8);

    --text-color: #5D5D5D;
    --text-muted: #888888;
    --border-color: rgba(255, 255, 255, 0.6);

    --radius: 24px;
    --shadow: 0 10px 25px -5px rgba(255, 143, 171, 0.3), 0 8px 10px -6px rgba(255, 143, 171, 0.1);
    --shadow-sm: 0 4px 6px -1px rgba(255, 143, 171, 0.1);
}

[data-theme="dark"] {
    /* Starry Night Theme */
    --primary-color: #FFB7B2;
    --primary-hover: #FF9E99;
    --secondary-color: #B5EAD7;
    --secondary-hover: #95DCC3;

    --bg-gradient-start: #2C3E50;
    --bg-gradient-end: #4CA1AF;

    --surface-color: rgba(30, 41, 59, 0.7);
    --surface-border: rgba(255, 255, 255, 0.1);

    --text-color: #F1F5F9;
    --text-muted: #CBD5E1;
    --border-color: rgba(255, 255, 255, 0.1);

    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', 'Nunito', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    background-attachment: fixed;
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Header */
header {
    background-color: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    height: 45px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-5px);
    }

    100% {
        transform: translateY(0px);
    }
}

h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

.theme-btn {
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid var(--surface-border);
    color: var(--text-color);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.theme-btn:hover {
    background-color: var(--surface-color);
    transform: rotate(15deg) scale(1.1);
}

/* Main Content */
main {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

/* Upload Section */
.upload-section {
    width: 100%;
}

.drop-zone {
    background-color: var(--surface-color);
    backdrop-filter: blur(10px);
    border: 3px dashed var(--primary-color);
    border-radius: var(--radius);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    box-shadow: var(--shadow);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--secondary-color);
    background-color: rgba(255, 255, 255, 0.9);
    transform: scale(1.02) translateY(-5px);
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary-color);
    filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.1));
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

.upload-text {
    font-size: 1.2rem;
    color: var(--text-color);
    font-weight: 600;
}

/* Controls */
.controls {
    background-color: var(--surface-color);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: var(--radius);
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    border: 1px solid var(--surface-border);
    animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bg-remove-group {
    background-color: rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 1px solid var(--surface-border);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
}

.checkbox-label input {
    width: 1.3rem;
    height: 1.3rem;
    accent-color: var(--primary-color);
    border-radius: 4px;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    background: none;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

input[type="color"]:hover {
    transform: scale(1.1);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 3px solid white;
    border-radius: 50%;
}

.icon-btn {
    padding: 0.5rem;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Eyedropper Mode */
body.eyedropper-active {
    cursor: crosshair !important;
}

body.eyedropper-active .crop-box {
    pointer-events: none;
}

.size-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

label {
    font-size: 0.9rem;
    color: var(--text-color);
    font-weight: 600;
}

input[type="number"] {
    background-color: rgba(255, 255, 255, 0.5);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    padding: 0.6rem;
    border-radius: 12px;
    width: 90px;
    font-size: 1rem;
    text-align: center;
    font-weight: 600;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 4px rgba(255, 143, 171, 0.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    /* Pill shape */
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Bouncy */
    border: none;
    font-size: 0.95rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-3px) scale(1.02);
}

.btn:active {
    transform: translateY(-1px) scale(0.98);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 15px rgba(255, 143, 171, 0.4);
}

.primary-btn:hover {
    box-shadow: 0 6px 20px rgba(255, 143, 171, 0.6);
}

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

.secondary-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.success-btn {
    background: linear-gradient(135deg, var(--success-color), var(--success-hover));
    color: #2D5A4C;
    box-shadow: 0 4px 15px rgba(168, 230, 207, 0.4);
}

.success-btn:hover {
    box-shadow: 0 6px 20px rgba(168, 230, 207, 0.6);
}

.text-btn {
    background: none;
    box-shadow: none;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 12px;
}

.text-btn:hover {
    color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
}

/* Workspace */
.workspace {
    flex: 1;
    background-color: var(--surface-color);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    border: 1px solid var(--surface-border);
    padding: 2rem;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    overflow: auto;
    min-height: 500px;
    position: relative;
    box-shadow: var(--shadow);
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.canvas-container {
    position: relative;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.15);
    user-select: none;
    border-radius: 12px;
    overflow: visible;
    border: 4px solid white;
    touch-action: none;
}

#targetImage {
    display: block;
    max-width: 100%;
    height: auto;
    pointer-events: none;
}

/* Crop Box */
.crop-box {
    position: absolute;
    border: 3px solid var(--primary-color);
    background-color: rgba(255, 143, 171, 0.2);
    cursor: move;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5), 0 8px 16px rgba(0, 0, 0, 0.1);
    transition: border-color 0.2s, background-color 0.2s;
    border-radius: 4px;
    touch-action: none;
}

.crop-box.active {
    border-color: var(--secondary-color);
    background-color: rgba(78, 205, 196, 0.2);
    z-index: 10;
}

/* Resize Handles */
.handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: white;
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    transform: translate(-50%, -50%);
    /* 增加透明點擊區域 */
}

.handle:hover {
    transform: scale(1.3);
}

.crop-box.active .handle {
    border-color: var(--secondary-color);
}

.handle-nw {
    top: -8px;
    left: -8px;
    cursor: nw-resize;
}

.handle-ne {
    top: -8px;
    right: -8px;
    cursor: ne-resize;
}

.handle-sw {
    bottom: -8px;
    left: -8px;
    cursor: sw-resize;
}

.handle-se {
    bottom: -8px;
    right: -8px;
    cursor: se-resize;
}

/* Box Controls */
.box-controls {
    position: absolute;
    top: -50px;
    right: 0;
    display: flex;
    gap: 8px;
    background-color: white;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.crop-box:hover .box-controls,
.crop-box.active .box-controls {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.box-btn {
    background: var(--bg-color);
    border: none;
    cursor: pointer;
    color: var(--text-color);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
}

.box-btn:hover {
    transform: scale(1.15) rotate(5deg);
}

.delete-btn:hover {
    color: #ef4444;
    background-color: #fef2f2;
}

.download-btn:hover {
    color: #10b981;
    background-color: #ecfdf5;
}

.copy-btn:hover {
    color: #3b82f6;
    background-color: #eff6ff;
}

/* Footer */
footer {
    background-color: var(--surface-color);
    backdrop-filter: blur(10px);
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--surface-border);
    margin-top: auto;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
}

footer a:hover {
    text-decoration: underline;
}

/* Tooltip */
.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    margin-left: 0.5rem;
}

.info-icon {
    font-size: 1.4rem;
    color: var(--secondary-color);
    transition: transform 0.2s;
}

.info-icon:hover {
    transform: scale(1.2) rotate(10deg);
}

.tooltip-text {
    visibility: hidden;
    background-color: white;
    color: var(--text-color);
    text-align: center;
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    position: absolute;
    z-index: 100;
    bottom: 140%;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    white-space: nowrap;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid var(--primary-color);
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -8px;
    border-width: 8px;
    border-style: solid;
    border-color: var(--primary-color) transparent transparent transparent;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Responsive */
@media (max-width: 768px) {
    input[type="color"] {
        width: 72px;
        height: 36px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .size-group {
        flex-direction: column;
        width: 100%;
    }

    .input-wrapper {
        width: 100%;
        justify-content: space-between;
    }

    .input-wrapper input {
        flex: 1;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .action-group {
        flex-direction: column;
        width: 100%;
    }
}

/* Zoom Group */
.zoom-group {
    background-color: rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: -15px;
}

.zoom-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    margin-right: 0.5rem;
}

.zoom-level {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 50px;
    text-align: center;
    margin-left: -15px;
}

#zoomLevel {
    margin: 0px;
}