/* ============ CSS Variables ============ */
:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #e8e8e8;
    --accent-color: #00d4ff;
    --accent-dark: #00bcd4;
    --text-dark: #1a1a1a;
    --text-color: #222222;
    --white: #ffffff;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 2px 12px rgba(0, 212, 255, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

/* ============ Reset & Base ============ */
.watermark-tool-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--bg-primary);
    min-height: 100vh;
    box-sizing: border-box;
}

.watermark-tool-wrapper *,
.watermark-tool-wrapper *::before,
.watermark-tool-wrapper *::after {
    box-sizing: border-box;
}

/* ============ Header ============ */
.watermark-header {
    text-align: center;
    padding: 30px 20px;
    margin-bottom: 30px;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm), var(--shadow-glow);
    border: 1px solid rgba(0, 212, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.watermark-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-dark), var(--accent-color));
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: -200% 0; }
    50% { background-position: 200% 0; }
}

.watermark-title {
    color: var(--text-dark);
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0 0 8px 0;
    letter-spacing: -0.5px;
}

.watermark-subtitle {
    color: #555;
    font-size: 1rem;
    margin: 0;
    font-weight: 400;
}

/* ============ Main Container ============ */
.watermark-container {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 24px;
    align-items: start;
}

/* ============ Control Panel ============ */
.control-panel {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.control-panel:hover {
    box-shadow: var(--shadow-md);
}

.control-panel h3 {
    color: var(--text-dark);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 16px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--bg-secondary);
}

/* ============ Upload Zone ============ */
.upload-zone {
    border: 2px dashed #ccc;
    border-radius: var(--border-radius-sm);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-primary);
    position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent-color);
    background: rgba(0, 212, 255, 0.05);
    box-shadow: var(--shadow-glow);
}

.upload-zone-small {
    padding: 20px;
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
}

.upload-content p {
    margin: 4px 0;
    color: #666;
    font-size: 0.9rem;
}

.upload-or {
    font-size: 0.8rem;
    color: #999;
}

/* ============ Buttons ============ */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
    text-align: center;
    background: var(--accent-color);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
    outline: none;
    user-select: none;
}

.btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.4);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
    filter: brightness(0.95);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
    transform: none;
    box-shadow: none;
}

.btn-upload {
    background: var(--accent-color);
    pointer-events: auto;
}

.btn-toggle {
    background: var(--bg-secondary);
    color: var(--text-color);
    box-shadow: none;
    margin-right: 8px;
}

.btn-toggle.active {
    background: var(--accent-color);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
}

.btn-download {
    width: 100%;
    padding: 14px 24px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-dark));
}

.btn-download-option {
    background: var(--bg-secondary);
    color: var(--text-color);
    box-shadow: none;
    margin: 4px;
}

.btn-download-option:hover {
    background: var(--accent-color);
    color: var(--white);
}

.toggle-group {
    display: flex;
    gap: 8px;
}

/* ============ Form Elements ============ */
.form-group {
    margin-bottom: 16px;
}

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

.form-group label {
    display: block;
    color: var(--text-dark);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-group.half {
    flex: 1;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    color: var(--text-color);
    transition: var(--transition);
    background: var(--white);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.color-picker {
    height: 42px;
    padding: 4px 8px;
    cursor: pointer;
}

.range-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 212, 255, 0.4);
    transition: var(--transition);
}

.range-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 212, 255, 0.4);
    border: none;
}

/* ============ Position Grid ============ */
.position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.pos-btn {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius-sm);
    background: var(--white);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    color: var(--text-color);
    text-align: center;
}

.pos-btn:hover {
    border-color: var(--accent-color);
    background: rgba(0, 212, 255, 0.05);
}

.pos-btn.active {
    background: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.4);
}

.checkbox-input {
    margin-right: 8px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

/* ============ Preview Panel ============ */
.preview-panel {
    height: 100%;
}

.preview-container {
    position: relative;
    width: 100%;
    min-height: 400px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid #e0e0e0;
    cursor: default;
}

.preview-canvas {
    max-width: 100%;
    max-height: 600px;
    display: block;
    object-fit: contain;
}

.preview-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-content {
    text-align: center;
    color: #999;
}

.placeholder-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
}

/* ============ Drag Handle ============ */
.drag-handle {
    position: absolute;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-color);
    color: var(--white);
    box-shadow: var(--shadow-md);
    z-index: 10;
    transition: transform 0.1s ease;
    font-size: 1.2rem;
    user-select: none;
}

.drag-handle:hover {
    transform: scale(1.1);
}

.drag-handle.dragging {
    transform: scale(1.2);
    box-shadow: var(--shadow-glow);
}

/* ============ Download Section ============ */
.download-section {
    margin-top: 16px;
    text-align: center;
}

.download-options {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============ Responsive Design ============ */
@media (max-width: 1024px) {
    .watermark-container {
        grid-template-columns: 1fr;
        max-width: 700px;
        margin: 0 auto;
    }
    
    .watermark-title {
        font-size: 1.8rem;
    }
}

@media (max-width: 768px) {
    .watermark-tool-wrapper {
        padding: 12px;
    }
    
    .watermark-header {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    
    .watermark-title {
        font-size: 1.5rem;
    }
    
    .watermark-subtitle {
        font-size: 0.85rem;
    }
    
    .control-panel {
        padding: 16px;
    }
    
    .control-panel h3 {
        font-size: 1rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .upload-zone {
        padding: 20px 15px;
    }
    
    .upload-icon {
        font-size: 2rem;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    .btn-download {
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    .preview-container {
        min-height: 300px;
    }
    
    .pos-btn {
        padding: 8px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .watermark-header {
        padding: 15px 10px;
    }
    
    .watermark-title {
        font-size: 1.3rem;
    }
    
    .toggle-group {
        flex-direction: column;
    }
    
    .position-grid {
        gap: 4px;
    }
    
    .pos-btn {
        padding: 6px;
        font-size: 0.9rem;
    }
}

/* Touch devices */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
        filter: none;
    }
    
    .btn:active {
        filter: brightness(1.1);
    }
    
    .pos-btn {
        min-height: 40px;
    }
    
    .range-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
}