/* ============================================================
   WaLinks Generator — Frontend Styles
   Inspired by w.app / WhatsApp brand design
   ============================================================ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
    --wl-green:        #25D366;
    --wl-green-dark:   #128C7E;
    --wl-green-xdark:  #075E54;
    --wl-green-light:  #dcf8c6;
    --wl-green-pale:   #f0faf3;
    --wl-blue:         #34B7F1;
    --wl-text:         #111b21;
    --wl-text-muted:   #667781;
    --wl-border:       #e9edef;
    --wl-border-focus: #25D366;
    --wl-bg:           #f0f2f5;
    --wl-white:        #ffffff;
    --wl-radius:       16px;
    --wl-radius-sm:    8px;
    --wl-shadow:       0 4px 24px rgba(0, 0, 0, 0.08);
    --wl-shadow-lg:    0 8px 40px rgba(0, 0, 0, 0.12);
    --wl-transition:   0.2s ease;
    --wl-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────── */
.walinks-wrap *,
.walinks-wrap *::before,
.walinks-wrap *::after {
    box-sizing: border-box;
}

/* ── Wrapper ─────────────────────────────────────────────────── */
.walinks-wrap {
    font-family: var(--wl-font);
    font-size: 15px;
    color: var(--wl-text);
    background: transparent;   /* Elementor/page provides the bg */
    border-radius: var(--wl-radius);
    padding: 0 0 32px;
    max-width: 1140px;
    margin: 0 auto;
    overflow: hidden;
}

/* ── Hero Header ─────────────────────────────────────────────── */
.walinks-hero {
    background: linear-gradient(135deg, var(--wl-green-xdark) 0%, var(--wl-green-dark) 50%, var(--wl-green) 100%);
    padding: 48px 40px 52px;
    text-align: center;
    color: var(--wl-white);
    position: relative;
    overflow: hidden;
}

.walinks-hero::before {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
}
.walinks-hero::after {
    content: '';
    position: absolute;
    bottom: -40px; left: -30px;
    width: 160px; height: 160px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
}

.walinks-hero__icon {
    width: 64px;
    height: 64px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.walinks-hero__icon svg {
    width: 36px;
    height: 36px;
    fill: var(--wl-white);
}

.walinks-hero__title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px;
    letter-spacing: -0.3px;
    position: relative;
}

.walinks-hero__subtitle {
    font-size: 15px;
    opacity: 0.85;
    margin: 0;
    position: relative;
}

/* ── Main Card ───────────────────────────────────────────────── */
.walinks-card {
    background: transparent;   /* no white box — page bg shows through */
    margin: 0 32px 0;
    border-radius: var(--wl-radius);
    box-shadow: none;
    padding: 36px;
    position: relative;
    z-index: 1;
}

/* ── Two-column layout ────────────────────────────────────────── */
.walinks-layout {
    display: grid;
    grid-template-columns: 1fr 330px;
    gap: 40px;
    align-items: start;
}
.walinks-layout--full {
    grid-template-columns: 1fr;
}

@media (max-width: 720px) {
    .walinks-layout {
        grid-template-columns: 1fr;
    }
    .walinks-preview-col {
        order: -1;
    }
    .walinks-card {
        margin: 0 16px 0;
        padding: 24px 20px;
    }
}

/* ── Form Field Group ────────────────────────────────────────── */
.walinks-field-group {
    margin-bottom: 24px;
}

.walinks-label {
    display: block;
    font-weight: 800 !important;
    font-size: 18px !important;
    color: var(--wl-text) !important;
    margin-bottom: 10px;
    line-height: 1.3;
}

.walinks-required {
    color: #e74c3c;
    margin-left: 2px;
}
.walinks-optional {
    font-weight: 400;
    font-size: 14px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--wl-text-muted);
    margin-left: 4px;
}

.walinks-hint {
    font-size: 12px;
    color: var(--wl-text-muted);
    margin: 6px 0 0;
}

/* ── Inputs ──────────────────────────────────────────────────── */
.walinks-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--wl-border);
    border-radius: var(--wl-radius-sm);
    font-family: var(--wl-font);
    font-size: 15px;
    color: #000;
    font-weight: 700;
    background: var(--wl-white);
    transition: border-color var(--wl-transition), box-shadow var(--wl-transition);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.walinks-input::placeholder {
    color: var(--wl-text-muted);
    font-weight: 400;
}
.walinks-input:focus {
    border-color: var(--wl-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}
.walinks-input.walinks-input--error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}
.walinks-textarea {
    resize: none;
    min-height: 100px;
    overflow: hidden;
    line-height: 1.5;
    font-weight: 700;
    color: #000;
}

/* ── Phone wrapper (intl-tel-input override) ─────────────────── */
.walinks-phone-wrapper {
    position: relative;
}
.walinks-phone-wrapper .iti {
    width: 100%;
}
.walinks-phone-wrapper .iti__selected-flag {
    border-radius: var(--wl-radius-sm) 0 0 var(--wl-radius-sm);
    background: var(--wl-bg);
    border-right: 1.5px solid var(--wl-border);
    padding: 0 8px 0 12px;
}
.walinks-phone-wrapper .iti--separate-dial-code .iti__selected-flag {
    background: var(--wl-green-pale);
}
.walinks-phone-wrapper .iti--separate-dial-code input {
    border-radius: var(--wl-radius-sm);
    border: 1.5px solid var(--wl-border);
    padding: 12px 14px;
    font-size: 15px;
    font-weight: 700;
    color: #000;
    height: auto;
    box-shadow: none;
}
.walinks-phone-wrapper .iti--separate-dial-code input:focus {
    border-color: var(--wl-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
    outline: none;
}

/* ── Custom Alias Field ──────────────────────────────────────── */
.walinks-alias-wrapper {
    display: flex;
    align-items: stretch;
}
.walinks-alias-prefix {
    display: flex;
    align-items: center;
    background: var(--wl-green-pale);
    border: 1.5px solid var(--wl-border);
    border-right: none;
    border-radius: var(--wl-radius-sm) 0 0 var(--wl-radius-sm);
    padding: 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--wl-green-dark);
    white-space: nowrap;
    flex-shrink: 0;
}
.walinks-alias-input {
    border-radius: 0 var(--wl-radius-sm) var(--wl-radius-sm) 0 !important;
    font-weight: 700;
    color: #000;
}

/* ── Formatting Toolbar ──────────────────────────────────────── */
.walinks-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 0;
    background: var(--wl-bg);
    border: 1.5px solid var(--wl-border);
    border-radius: var(--wl-radius-sm) var(--wl-radius-sm) 0 0;
    padding: 6px 10px;
    position: relative;
}
.walinks-toolbar-btn {
    padding: 4px 10px;
    background: #006838 !important;
    border: 1px solid #006838 !important;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #ffffff !important;
    transition: all var(--wl-transition);
    line-height: 1;
}
.walinks-toolbar-btn:hover {
    background: #47b65c !important;
    border-color: #47b65c !important;
    color: #ffffff !important;
}
.walinks-toolbar-divider {
    width: 1px;
    height: 18px;
    background: var(--wl-border);
    margin: 0 4px;
    flex-shrink: 0;
}
.walinks-emoji-toggle {
    font-size: 16px;
    padding: 3px 8px;
}
.walinks-toolbar-sep {
    flex: 1;
}
.walinks-char-count {
    font-size: 11px;
    color: var(--wl-text-muted);
    white-space: nowrap;
}
.walinks-toolbar + .walinks-emoji-picker + .walinks-textarea,
.walinks-toolbar + .walinks-textarea,
.walinks-textarea--notop {
    border-top: none;
    border-radius: 0 0 var(--wl-radius-sm) var(--wl-radius-sm);
}

/* ── Emoji Picker ────────────────────────────────────────────── */
.walinks-emoji-picker {
    background: var(--wl-white);
    border: 1.5px solid var(--wl-border);
    border-top: none;
    border-bottom: none;
    padding: 10px;
    max-height: 160px;
    overflow-y: auto;
}
.walinks-emoji-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.walinks-emoji-btn {
    background: none;
    border: none;
    padding: 4px 5px;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    line-height: 1;
    transition: background var(--wl-transition);
    flex-shrink: 0;
}
.walinks-emoji-btn:hover {
    background: var(--wl-bg);
}

/* ── Submit Button ───────────────────────────────────────────── */
.walinks-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 24px;
    border-radius: var(--wl-radius-sm);
    font-family: var(--wl-font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--wl-transition);
    border: 2px solid transparent;
    line-height: 1;
    white-space: nowrap;
}
.walinks-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.walinks-btn--primary {
    background: #006838 !important;
    color: #ffffff !important;
    width: 100%;
    font-size: 16px;
    font-weight: 700;
    padding: 15px 28px;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0, 104, 56, 0.35);
    border-color: #006838 !important;
}
.walinks-btn--primary:hover:not(:disabled) {
    background: #47b65c !important;
    border-color: #47b65c !important;
    box-shadow: 0 6px 20px rgba(71, 182, 92, 0.40);
    transform: translateY(-1px);
}
.walinks-btn--primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}
.walinks-btn--green {
    background: #006838 !important;
    color: #ffffff !important;
    border-color: #006838 !important;
}
.walinks-btn--green:hover {
    background: #47b65c !important;
    border-color: #47b65c !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}
.walinks-btn--green svg {
    fill: #ffffff !important;
}
.walinks-btn--outline {
    background: #006838 !important;
    border-color: #006838 !important;
    color: #ffffff !important;
}
.walinks-btn--outline:hover {
    background: #47b65c !important;
    border-color: #47b65c !important;
    color: #ffffff !important;
}
.walinks-btn--outline svg {
    fill: #ffffff !important;
}
.walinks-btn--sm {
    padding: 8px 14px;
    font-size: 13px;
}

/* Spinner */
.walinks-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: var(--wl-white);
    border-radius: 50%;
    animation: walinks-spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes walinks-spin {
    to { transform: rotate(360deg); }
}

/* ── Alert ───────────────────────────────────────────────────── */
.walinks-alert {
    padding: 12px 16px;
    border-radius: var(--wl-radius-sm);
    font-size: 14px;
    margin-bottom: 20px;
}
.walinks-alert--error {
    background: #fff0f0;
    color: #c0392b;
    border: 1px solid #fad0cd;
}

/* ── Phone Preview Image ─────────────────────────────────────── */
.walinks-preview-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 8px;
}

.walinks-preview-img-wrap {
    position: relative;        /* anchor for overlay children */
    width: 100%;
    max-width: 330px;
    aspect-ratio: 9 / 16;     /* 1080×1920 */
    max-height: 586px;
    overflow: visible;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.walinks-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
    mix-blend-mode: multiply;  /* makes white PNG bg transparent */
}

/* ── Live preview overlay ────────────────────────────────────── */
.walinks-preview-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

/* Phone number — WhatsApp system chip, centered at top of chat area */
.walinks-preview-phone-label {
    position: absolute;
    top: 16%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(255,255,255,0.95);
    background: rgba(0,0,0,0.35);
    border-radius: 12px;
    padding: 3px 12px;
    white-space: nowrap;
    font-weight: 700;
    font-family: var(--wl-font);
    max-width: 60%;        /* keep within phone screen */
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    letter-spacing: 0.1px;
    backdrop-filter: blur(2px);
}

/* Message bubble — left-aligned inside phone screen, with proper inset from bezel */
.walinks-preview-bubble {
    position: absolute;
    top: 25%;
    left: 19%;
    right: auto;
    max-width: 63%;
    max-height: 52%;        /* cap so bubble never exits phone frame bottom */
    overflow: hidden;       /* clip any overflow — safety net */
    background: #dcf8c6;
    border-radius: 0px 8px 8px 8px;
    padding: 8px 10px 6px;
    font-size: 13px;
    color: #000;
    font-family: var(--wl-font);
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.walinks-preview-bubble strong { font-weight: 700; }
.walinks-preview-bubble em { font-style: italic; }
.walinks-preview-bubble s   { text-decoration: line-through; }
.walinks-preview-bubble code { font-family: monospace; font-size: 10px; }

.walinks-preview-placeholder {
    color: #999;
    font-style: italic;
    font-size: 10px;
}

/* Preview disclaimer — just above the WhatsApp input bar */
.walinks-preview-note {
    position: absolute;
    bottom: 17%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    font-size: 8.5px;
    color: rgba(0, 0, 0, 0.40);
    text-align: center;
    width: 74%;
    line-height: 1.35;
    pointer-events: none;
}

/* Arabic RTL bubble */
.walinks-preview-bubble[dir="rtl"] {
    direction: rtl;
    text-align: right;
    unicode-bidi: embed;
}

/* ── Result Panel ────────────────────────────────────────────── */
.walinks-result {
    background: var(--wl-white);
    margin: 20px 32px 0;
    border-radius: var(--wl-radius);
    box-shadow: var(--wl-shadow);
    padding: 32px 36px;
    animation: walinks-slide-in 0.4s ease;
}

/* ── Powered by Rabit footer ─────────────────────────────────── */
.walinks-powered-by {
    text-align: center;
    font-size: 11px;
    color: var(--wl-text-muted);
    margin-top: 14px;
    opacity: 0.75;
    letter-spacing: 0.2px;
}
.walinks-powered-by a {
    color: var(--wl-green-dark);
    text-decoration: none;
    font-weight: 500;
}
.walinks-powered-by a:hover {
    text-decoration: underline;
}

@keyframes walinks-slide-in {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 680px) {
    .walinks-result {
        margin: 16px 16px 0;
        padding: 24px 20px;
    }
}

.walinks-result__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.walinks-result__check {
    width: 36px;
    height: 36px;
    background: var(--wl-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.walinks-result__check svg {
    width: 20px;
    height: 20px;
    fill: var(--wl-white);
}
.walinks-result__header h3 {
    font-size: 22px !important;
    font-weight: 800 !important;
    margin: 0;
    color: var(--wl-text) !important;
}

.walinks-result__body {
    display: grid;
    grid-template-columns: 1fr 160px;
    gap: 32px;
    align-items: start;
}
@media (max-width: 680px) {
    .walinks-result__body {
        grid-template-columns: 1fr;
    }
    .walinks-result__qr {
        order: -1;
    }
}

/* URL rows */
.walinks-result__url-row {
    margin-bottom: 16px;
}
.walinks-result__url-row label {
    display: block;
    font-size: 16px !important;
    font-weight: 800 !important;
    text-transform: none;
    letter-spacing: 0;
    color: var(--wl-text) !important;
    margin-bottom: 8px;
}

.walinks-url-copy {
    display: flex;
    gap: 8px;
}
.walinks-url-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--wl-border);
    border-radius: var(--wl-radius-sm);
    font-size: 13px;
    font-family: monospace;
    color: var(--wl-text);
    background: var(--wl-bg);
    outline: none;
    min-width: 0;
}
.walinks-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: #006838 !important;
    border: 1.5px solid #006838 !important;
    border-radius: var(--wl-radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: #ffffff !important;
    white-space: nowrap;
    transition: all var(--wl-transition);
    flex-shrink: 0;
}
.walinks-copy-btn svg {
    width: 14px;
    height: 14px;
    fill: #ffffff !important;
}
.walinks-copy-btn:hover {
    background: #47b65c !important;
    border-color: #47b65c !important;
    color: #ffffff !important;
}
.walinks-copy-btn.copied {
    background: #47b65c !important;
    border-color: #47b65c !important;
    color: #ffffff !important;
}

.walinks-result__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* QR column */
.walinks-result__qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.walinks-qr-box {
    width: 144px;
    height: 144px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wl-bg);
    border: 1.5px solid var(--wl-border);
    border-radius: 12px;
    overflow: hidden;
}
.walinks-qr-box img,
.walinks-qr-box canvas {
    width: 128px !important;
    height: 128px !important;
    display: block;
}
.walinks-qr-loading {
    font-size: 12px;
    color: var(--wl-text-muted);
    text-align: center;
}

/* ── Powered by / footer ─────────────────────────────────────── */
.walinks-powered {
    text-align: center;
    margin-top: 16px;
    font-size: 11px;
    color: var(--wl-text-muted);
}
.walinks-powered a {
    color: var(--wl-green-dark);
    text-decoration: none;
    font-weight: 600;
}
