/* ===== Design Tokens ===== */
:root {
    --color-bg: #fde8db;
    --color-bg-gradient: linear-gradient(135deg, #fde8db 0%, #fdd6c0 50%, #fce4d4 100%);
    --color-primary: #ee4d2d;
    --color-primary-hover: #d73a1f;
    --color-primary-light: #fff0ed;
    --color-white: #ffffff;
    --color-text: #333333;
    --color-text-light: #666666;
    --color-text-muted: #999999;
    --color-border: #e0e0e0;
    --color-success: #27ae60;
    --color-success-bg: #e8f8f0;
    --color-fb-blue: #1877f2;
    --color-voucher-orange: #ee4d2d;
    --color-voucher-bg: linear-gradient(135deg, #ee4d2d 0%, #f97316 100%);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 1.75rem;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.08);

    --transition: all 0.2s ease;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg-gradient);
    min-height: 100vh;
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Header ===== */
.header {
    text-align: center;
    padding: 40px 20px 20px;
}

.header__title {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.header__icon {
    font-size: 1.5rem;
}

.header__subtitle {
    display: inline-block;
    font-size: var(--font-size-xs);
    color: var(--color-primary);
    background: var(--color-primary-light);
    padding: 4px 16px;
    border-radius: var(--radius-full);
    cursor: default;
    user-select: none;
}

/* ===== Container ===== */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

/* ===== Card ===== */
.card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
}

/* ===== Input Section ===== */
.input-section {
    margin-bottom: 0;
}

.input-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 10px;
}

.input-label__icon {
    font-size: 1rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    margin-bottom: 14px;
}

.input-wrapper:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(238, 77, 45, 0.1);
}

.input-field {
    flex: 1;
    border: none;
    outline: none;
    padding: 14px 16px;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    color: var(--color-text);
    background: transparent;
}

.input-field::placeholder {
    color: var(--color-text-muted);
}

.paste-btn {
    background: none;
    border: none;
    padding: 14px 14px;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.paste-btn:hover {
    color: var(--color-primary);
}

.paste-btn:active {
    transform: scale(0.9);
}

/* ===== Generate Button ===== */
.generate-btn {
    width: 100%;
    padding: 16px;
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(238, 77, 45, 0.3);
}

.generate-btn:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(238, 77, 45, 0.4);
}

.generate-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(238, 77, 45, 0.3);
}

/* ===== Result Section ===== */
.result-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
    animation: fadeSlideIn 0.3s ease;
}

.result-box {
    background: var(--color-success-bg);
    border: 1px solid #c3e6cb;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 12px;
    word-break: break-all;
}

.result-text {
    font-size: var(--font-size-sm);
    color: var(--color-success);
    font-weight: 500;
    line-height: 1.5;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.action-btn--copy {
    background: var(--color-primary);
    color: var(--color-white);
}

.action-btn--copy:hover {
    background: var(--color-primary-hover);
}

.action-btn--open {
    background: #f5f5f5;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.action-btn--open:hover {
    background: #ebebeb;
}

.action-btn:active {
    transform: scale(0.97);
}

/* ===== Instructions ===== */
.instructions {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.instructions__title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-sm);
    margin-bottom: 10px;
    color: var(--color-text);
}

.instructions__icon {
    font-size: 1rem;
}

.instructions__list {
    padding-left: 20px;
    margin-bottom: 16px;
}

.instructions__list li {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    margin-bottom: 4px;
    line-height: 1.6;
}

.fb-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 2px solid var(--color-fb-blue);
    border-radius: var(--radius-sm);
    color: var(--color-fb-blue);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.fb-link:hover {
    background: var(--color-fb-blue);
    color: var(--color-white);
}

.fb-link svg {
    flex-shrink: 0;
}

/* ===== Voucher Section ===== */
.voucher-section {
    margin-bottom: 24px;
}

.voucher-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.back-arrow {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    transition: var(--transition);
}

.back-arrow:hover {
    transform: translateX(-3px);
}

.voucher-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text);
}

.voucher-card {
    background: var(--color-voucher-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    box-shadow: var(--shadow-md);
    position: relative;
}

/* Zigzag/ticket edge effect */
.voucher-card::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 8px,
            var(--color-bg) 8px,
            var(--color-bg) 16px);
}

.voucher-card__left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 24px;
    min-width: 100px;
    border-right: 2px dashed rgba(255, 255, 255, 0.3);
}

.voucher-card__logo {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.voucher-card__platform {
    color: var(--color-white);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.voucher-card__right {
    padding: 16px 20px;
    color: var(--color-white);
    flex: 1;
}

.voucher-card__discount {
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin-bottom: 4px;
}

.voucher-card__min-order {
    font-size: var(--font-size-sm);
    opacity: 0.9;
    margin-bottom: 8px;
}

.voucher-card__badge {
    display: inline-block;
    padding: 2px 10px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
    margin-bottom: 8px;
}

.voucher-card__usage {
    font-size: var(--font-size-xs);
    opacity: 0.8;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-text);
    color: var(--color-white);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== Settings Panel ===== */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.settings-panel {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease;
}

.settings-panel__title {
    font-size: var(--font-size-lg);
    margin-bottom: 20px;
}

.settings-field {
    margin-bottom: 16px;
}

.settings-field label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--color-text-light);
}

.settings-field input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    transition: var(--transition);
}

.settings-field input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.settings-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.settings-btn {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.settings-btn--save {
    background: var(--color-primary);
    color: var(--color-white);
}

.settings-btn--save:hover {
    background: var(--color-primary-hover);
}

.settings-btn--cancel {
    background: #f5f5f5;
    color: var(--color-text);
}

.settings-btn--cancel:hover {
    background: #e8e8e8;
}

/* ===== Animations ===== */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== Responsive ===== */
/* ===== Password Panel ===== */
.password-panel {
    max-width: 340px;
}

.password-hint {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    margin-bottom: 16px;
}

.password-error {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    margin-top: 8px;
    font-weight: 500;
}

.password-locked {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: 8px;
    font-weight: 500;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

.shake {
    animation: shake 0.4s ease;
    border-color: var(--color-primary) !important;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .header {
        padding: 28px 16px 16px;
    }

    .header__title {
        font-size: var(--font-size-xl);
    }

    .card {
        padding: 20px;
    }

    .voucher-card__left {
        padding: 16px;
        min-width: 80px;
    }

    .voucher-card__discount {
        font-size: var(--font-size-base);
    }

    .result-actions {
        flex-direction: column;
    }
}