@import url('https://api.fontshare.com/v2/css?f[]=satoshi@400,500,600,700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-bg: #fafbfc;
    --color-surface: #ffffff;
    --color-primary: #09377e;
    --color-primary-hover: #072a5f;
    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-input-bg: #ffffff;
    --color-input-border: #e2e8f0;
    --color-preview-bg: #f1f5f9;
    --color-success: #16a34a;
    --color-shadow: rgba(0, 0, 0, 0.03);
    --color-shadow-md: rgba(0, 0, 0, 0.05);
    --color-ring: #09377e;
    --radius: 0.75rem;
    --radius-sm: 0.5rem;
}

body {
    font-family: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    padding: 24px;
    animation: fadeIn 0.4s ease-out;
    font-feature-settings: "ss01", "ss02", "cv01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

.header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 48px;
    animation: fadeIn 0.6s ease-in 0.1s both;
}

.header-logo {
    width: 144px;
    height: 144px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    animation: fadeIn 0.6s ease-in 0.2s both;
}

.form-section,
.preview-section {
    background: var(--color-surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: 0 1px 2px var(--color-shadow-md);
    border: 1px solid var(--color-border);
}

.form-section h2,
.preview-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--color-text);
}

.input-group {
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    height: 36px;
    padding: 8px 40px 8px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text);
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px var(--color-shadow);
}

.input-wrapper textarea {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text);
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px var(--color-shadow);
    font-family: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    resize: vertical;
    min-height: 60px;
}

.input-wrapper input:focus,
.input-wrapper textarea:focus {
    outline: none;
    border-color: var(--color-ring);
    box-shadow: 0 0 0 1px var(--color-ring);
}

.input-wrapper input::placeholder,
.input-wrapper textarea::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

.clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    line-height: 1;
}

.clear-btn:hover {
    color: var(--color-text);
}

.input-wrapper input:not(:placeholder-shown) ~ .clear-btn {
    display: flex;
}

.checkbox-group {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.preview-header {
    margin-bottom: 16px;
}

.preview-header h2 {
    margin: 0;
}

.preview-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.toggle-group {
    display: flex;
    gap: 4px;
    background: var(--color-preview-bg);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.toggle-btn {
    padding: 6px 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.toggle-btn:hover {
    color: var(--color-text);
}

.toggle-btn.active {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 1px 2px var(--color-shadow);
}

.preview-box {
    background: var(--color-preview-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 24px;
    min-height: 280px;
    margin-bottom: 24px;
    transition: all 0.2s ease;
}

.preview-box.dark-mode {
    background: #0c1222;
    border-color: #334155;
}


#signaturePreview {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    flex: 1;
    height: 36px;
    padding: 0 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 1px 2px var(--color-shadow);
}

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

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 2px var(--color-shadow);
}

.btn-secondary:hover {
    background: var(--color-preview-bg);
}

.btn-secondary:active {
    transform: scale(0.98);
}

.success-message {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--color-success);
    color: white;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.success-message.show {
    opacity: 1;
    transform: translateY(0);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-content {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.2s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--color-text-muted);
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    line-height: 1;
}

.modal-close:hover {
    background: var(--color-preview-bg);
    color: var(--color-text);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 73px);
}

.import-instructions {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.instruction-item {
    padding-bottom: 28px;
    border-bottom: 1px solid var(--color-border);
}

.instruction-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.instruction-item h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-primary);
}

.instruction-item ol {
    padding-left: 24px;
    margin: 0;
}

.instruction-item li {
    margin-bottom: 8px;
    color: var(--color-text);
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    .header {
        gap: 12px;
    }

    .header-logo {
        width: 120px;
        height: 120px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .form-section,
    .preview-section {
        padding: 20px;
    }

    .preview-box {
        padding: 20px;
        min-height: 200px;
    }

    .preview-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .toggle-group {
        width: 100%;
    }

    .toggle-btn {
        flex: 1;
    }

    .action-buttons {
        flex-direction: column;
    }

    .modal-content {
        margin: 0;
    }

    .modal-header,
    .modal-body {
        padding: 20px;
    }

    .instruction-item h3 {
        font-size: 1.125rem;
    }
}

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

    .form-section h2,
    .preview-section h2 {
        font-size: 1.25rem;
    }
}
