* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    touch-action: manipulation;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --dark: #1f2937;
    --gray: #6b7280;
    --light-gray: #f3f4f6;
    --white: #ffffff;
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--dark);
}

.language-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--white);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-link {
    color: var(--gray);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: color 0.3s ease;
    padding: 8px 12px;
    border-radius: 4px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    touch-action: manipulation;
}

.lang-link:hover {
    color: var(--primary);
}

.lang-link.active {
    color: var(--primary);
    background: var(--light-gray);
}

.lang-separator {
    color: var(--border);
    font-weight: 300;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: var(--white);
    margin-bottom: 40px;
    animation: fadeInDown 0.6s ease;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    animation: fadeIn 0.6s ease;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    min-height: 44px;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: var(--white);
    color: var(--primary);
    border-color: var(--white);
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

.card {
    background: var(--white);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 30px var(--shadow);
    margin-bottom: 30px;
}

.card h2 {
    color: var(--dark);
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.description {
    color: var(--gray);
    margin-bottom: 25px;
    line-height: 1.6;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

input[type="file"] {
    width: 100%;
    padding: 12px 20px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    cursor: pointer;
    background: var(--light-gray);
    transition: all 0.3s ease;
}

input[type="file"]:hover {
    background: var(--border);
    border-color: var(--primary);
}

input[type="file"]::file-selector-button {
    padding: 12px 20px;
    border: none;
    background: var(--primary);
    color: var(--white);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    margin-right: 12px;
    min-height: 44px;
    touch-action: manipulation;
}

input[type="file"]::file-selector-button:hover {
    background: var(--primary-dark);
}

input[type="color"] {
    width: 60px;
    height: 48px;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
    touch-action: manipulation;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker-wrapper span {
    font-family: monospace;
    font-size: 14px;
    color: var(--gray);
    font-weight: 600;
}

.font-preview {
    float: right;
    font-size: 20px;
    color: var(--primary);
    font-weight: 500;
    padding: 4px 12px;
    background: var(--light-gray);
    border-radius: 6px;
    margin-top: -2px;
}

.image-preview {
    margin-top: 15px;
    display: flex;
    justify-content: center;
}

.image-preview img {
    max-width: 100%;
    width: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: 8px;
    border: 2px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-preview-container {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    position: relative;
    width: 100%;
}

.image-preview-container img {
    max-width: 100%;
    width: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: 8px;
    border: 2px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.watermark-wrapper {
    position: absolute;
    pointer-events: none;
    z-index: 10;
}

.watermark-overlay {
    position: absolute !important;
    pointer-events: none;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    white-space: nowrap;
}

/* Split Layout for Watermark Tab */
.split-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-section {
    flex: 1;
    order: 1;
}

.preview-section {
    flex: 1;
    display: block;
    order: -1;
}

.preview-sticky {
    background: var(--white);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 20px var(--shadow);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.preview-title {
    color: var(--dark);
    font-size: 1.2rem;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
    flex-shrink: 0;
}

/* Desktop Layout: Side-by-side with sticky preview */
@media (min-width: 1024px) {
    .split-layout {
        flex-direction: row;
        align-items: flex-start;
        gap: 30px;
    }
    
    .form-section {
        flex: 0 0 55%;
        max-width: 55%;
        order: 0;
    }
    
    .preview-section {
        flex: 0 0 40%;
        max-width: 40%;
        display: block;
        position: sticky;
        top: 20px;
        max-height: calc(100vh - 40px);
        order: 0;
    }
    
    .preview-sticky {
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .preview-section .image-preview-container {
        display: flex !important;
        align-items: center;
        justify-content: center;
        flex: 1;
        overflow: hidden;
        position: relative;
        width: 100%;
        height: 100%;
        min-height: 500px;
    }
    
    .preview-section .image-preview-container img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        border-radius: 8px;
        border: 2px solid var(--border);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
}

/* Show preview when image is uploaded */
.preview-section .image-preview-container:not(:empty) {
    display: flex !important;
}


input[type="text"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    font-family: inherit;
    text-align: center;
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--light-gray);
    outline: none;
    -webkit-appearance: none;
    touch-action: pan-y;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.btn {
    width: 100%;
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 48px;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary.loading {
    pointer-events: none;
}

.btn-primary.loading .btn-text {
    opacity: 0;
}

.btn-primary.loading .loader {
    opacity: 1;
}

.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    opacity: 0;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.preview {
    margin-top: 20px;
}

.preview img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
}

.preview .success-message {
    background: var(--success);
    color: var(--white);
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview .download-btn {
    background: var(--success);
    width: auto;
    display: inline-block;
    margin-top: 10px;
}

.preview .download-btn:hover {
    background: #059669;
}

.info-section {
    background: var(--white);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 30px var(--shadow);
    margin-bottom: 30px;
}

.info-section h3 {
    color: var(--dark);
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.tips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.tip-card {
    background: var(--light-gray);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.tip-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px var(--shadow);
}

.tip-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.tip-card h4 {
    color: var(--dark);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.tip-card p {
    color: var(--gray);
    font-size: 0.9rem;
    line-height: 1.5;
}

footer {
    text-align: center;
    color: var(--white);
    padding: 20px 0;
    opacity: 0.9;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .card {
        padding: 20px;
    }

    .card h2 {
        font-size: 1.5rem;
    }

    .tabs {
        flex-direction: column;
    }

    .tips {
        grid-template-columns: 1fr;
    }
    
    .preview-section {
        margin-bottom: 20px;
    }
    
    .preview-sticky {
        min-height: 300px;
    }
    
    input[type="text"],
    input[type="email"],
    textarea,
    select {
        font-size: 16px;
    }
    
    .tab-btn {
        padding: 18px 20px;
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }

    .card {
        padding: 15px;
    }
}
