/* ============================================================
   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: var(--wl-bg);
    border-radius: var(--wl-radius);
    padding: 0 0 32px;
    max-width: 960px;
    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: var(--wl-white);
    margin: -24px 32px 0;
    border-radius: var(--wl-radius);
    box-shadow: var(--wl-shadow);
    padding: 36px;
    position: relative;
    z-index: 1;
}

/* ── Two-column layout ────────────────────────────────────────── */
.walinks-layout {
    display: grid;
    grid-template-columns: 1fr 230px;
    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: -24px 16px 0;
        padding: 24px 20px;
    }
    .walinks-hero {
        padding: 36px 24px 44px;
    }
    .walinks-hero__title {
        font-size: 22px;
    }
}

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

.walinks-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--wl-text);
    margin-bottom: 8px;
}

.walinks-required {
    color: #e74c3c;
    margin-left: 2px;
}
.walinks-optional {
    font-weight: 400;
    font-size: 12px;
    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: vertical;
    min-height: 100px;
    line-height: 1.5;
    font-weight: 700;
}

/* ── 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: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--wl-text);
    transition: all var(--wl-transition);
    line-height: 1;
}
.walinks-toolbar-btn:hover {
    background: var(--wl-white);
    border-color: var(--wl-border);
}
.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: var(--wl-green);
    color: var(--wl-white);
    width: 100%;
    font-size: 16px;
    padding: 15px 28px;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.35);
}
.walinks-btn--primary:hover:not(:disabled) {
    background: var(--wl-green-dark);
    box-shadow: 0 6px 20px rgba(18, 140, 126, 0.40);
    transform: translateY(-1px);
}
.walinks-btn--primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}
.walinks-btn--green {
    background: var(--wl-green);
    color: var(--wl-white);
}
.walinks-btn--green:hover {
    background: var(--wl-green-dark);
    transform: translateY(-1px);
}
.walinks-btn--outline {
    background: transparent;
    border-color: var(--wl-border);
    color: var(--wl-text);
}
.walinks-btn--outline:hover {
    border-color: var(--wl-green);
    color: var(--wl-green-dark);
    background: var(--wl-green-pale);
}
.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;
}

/* ── iPhone 15 Pro Preview (Black Titanium) ──────────────────── */
.walinks-preview-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 8px;
}

/* Outer container that holds frame + side buttons */
.walinks-iphone {
    position: relative;
    width: 210px;
    flex-shrink: 0;
}

/* ── Black Titanium frame ────── */
.walinks-iphone-frame {
    background: linear-gradient(
        160deg,
        #3a3a3c 0%,
        #2a2a2c 20%,
        #3d3d3f 40%,
        #1c1c1e 55%,
        #38383a 70%,
        #2c2c2e 85%,
        #3a3a3c 100%
    );
    border-radius: 46px;
    padding: 8px;
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.06),
        0 0 0 2px rgba(0,0,0,0.95),
        0 32px 96px rgba(0,0,0,0.65),
        0 6px 16px rgba(0,0,0,0.4);
    position: relative;
}

/* ── Side buttons (dark titanium) ── */
.walinks-iphone-btn {
    position: absolute;
    border-radius: 2px;
    z-index: 2;
    background: linear-gradient(
        to bottom,
        #48484a,
        #5a5a5c 35%,
        #48484a 65%,
        #3c3c3e
    );
}

/* Action button (short, top-left) */
.walinks-iphone-btn--action {
    left: -4px;
    top: 68px;
    width: 4px;
    height: 26px;
    border-radius: 3px 0 0 3px;
    box-shadow: -1px 0 3px rgba(0,0,0,0.5);
}

/* Volume up */
.walinks-iphone-btn--vol-up {
    left: -4px;
    top: 106px;
    width: 4px;
    height: 38px;
    border-radius: 3px 0 0 3px;
    box-shadow: -1px 0 3px rgba(0,0,0,0.5);
}

/* Volume down */
.walinks-iphone-btn--vol-down {
    left: -4px;
    top: 154px;
    width: 4px;
    height: 38px;
    border-radius: 3px 0 0 3px;
    box-shadow: -1px 0 3px rgba(0,0,0,0.5);
}

/* Power button (right, tall) */
.walinks-iphone-btn--power {
    right: -4px;
    top: 118px;
    width: 4px;
    height: 62px;
    border-radius: 0 3px 3px 0;
    box-shadow: 1px 0 3px rgba(0,0,0,0.5);
}

/* ── Screen ── */
.walinks-iphone-screen {
    background: var(--wl-bg);
    border-radius: 38px;
    overflow: hidden;
    height: 416px;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ── Dynamic Island (pure black pill) ── */
.walinks-dynamic-island {
    position: absolute;
    top: 9px;
    left: 50%;
    transform: translateX(-50%);
    width: 92px;
    height: 28px;
    background: #000;
    border-radius: 22px;
    z-index: 30;
    pointer-events: none;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.3);
}

/* ── Status Bar ── */
.walinks-status-bar {
    background: var(--wl-green-dark);
    padding: 46px 14px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.wl-status-time {
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.wl-status-icons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wl-status-icons svg {
    fill: #fff;
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

/* ── WA Chat Header ── */
.walinks-chat-header {
    background: var(--wl-green-dark);
    padding: 6px 10px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.wl-back-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: default;
    flex-shrink: 0;
}
.wl-back-btn svg {
    fill: #fff;
    width: 18px;
    height: 18px;
    display: block;
}

.walinks-chat-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}
.walinks-chat-avatar svg {
    width: 100%;
    height: 100%;
}
.walinks-chat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.walinks-chat-name {
    color: var(--wl-white);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.walinks-chat-status {
    color: rgba(255,255,255,0.75);
    font-size: 9px;
}

.wl-header-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}
.wl-header-actions svg {
    fill: #fff;
    width: 16px;
    height: 16px;
}

/* ── Chat Body ── */
.walinks-chat-body {
    flex: 1;
    padding: 10px 8px;
    background-color: #e5ddd5;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

.walinks-chat-datestamp {
    text-align: center;
    font-size: 9px;
    color: #667781;
    background: rgba(255,255,255,0.75);
    border-radius: 6px;
    padding: 2px 8px;
    display: inline-block;
    align-self: center;
    margin-bottom: 2px;
}

.walinks-chat-bubble {
    background: var(--wl-green-light);
    border-radius: 8px 0 8px 8px;
    padding: 6px 8px 4px;
    align-self: flex-end;
    max-width: 92%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
    position: relative;
}

.walinks-chat-bubble::after {
    content: '';
    position: absolute;
    top: 0; right: -6px;
    width: 0; height: 0;
    border-top: 6px solid var(--wl-green-light);
    border-right: 6px solid transparent;
}

.walinks-preview-placeholder {
    color: var(--wl-text-muted);
    font-style: italic;
    font-size: 10px;
    margin: 0;
}

#walinks-preview-text {
    font-size: 10px;
    color: var(--wl-text);
    margin: 0 0 3px;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
}

.walinks-bubble-time {
    font-size: 8px;
    color: var(--wl-text-muted);
    display: flex;
    align-items: center;
    gap: 2px;
    justify-content: flex-end;
}
.walinks-bubble-time svg { fill: #53bdeb; }

/* ── Chat Input Bar ── */
.walinks-chat-bar {
    background: var(--wl-bg);
    padding: 5px 8px;
    display: flex;
    align-items: center;
    gap: 5px;
    border-top: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.wl-chat-bar-emoji {
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
}

.wl-chat-bar-input {
    flex: 1;
    background: var(--wl-white);
    border-radius: 20px;
    padding: 5px 10px;
    font-size: 9px;
    color: var(--wl-text-muted);
    border: none;
    font-family: var(--wl-font);
}

.wl-chat-bar-mic {
    width: 26px;
    height: 26px;
    background: var(--wl-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.wl-chat-bar-mic svg {
    fill: #fff;
    width: 13px;
    height: 13px;
}

/* ── Preview text formatting ── */
#walinks-preview-text strong { font-weight: 700; }
#walinks-preview-text em     { font-style: italic; }
#walinks-preview-text s      { text-decoration: line-through; }
#walinks-preview-text code   { font-family: monospace; font-size: 9px; background: rgba(0,0,0,0.07); padding: 0 2px; border-radius: 2px; }

.walinks-preview-label {
    font-size: 11px;
    color: var(--wl-text-muted);
    margin-top: 10px;
    text-align: center;
}

/* ── 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;
}

@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: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--wl-text);
}

.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: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--wl-text-muted);
    margin-bottom: 6px;
}

.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: var(--wl-white);
    border: 1.5px solid var(--wl-border);
    border-radius: var(--wl-radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--wl-text);
    white-space: nowrap;
    transition: all var(--wl-transition);
    flex-shrink: 0;
}
.walinks-copy-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}
.walinks-copy-btn:hover {
    border-color: var(--wl-green);
    color: var(--wl-green-dark);
    background: var(--wl-green-pale);
}
.walinks-copy-btn.copied {
    background: var(--wl-green-pale);
    border-color: var(--wl-green);
    color: var(--wl-green-dark);
}

.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;
}
