/* ============================================================
   QickLink — Stylesheet (Fixed & Optimised)
   ============================================================ */

/* --- Google Fonts (display-swap = zero layout shift) ------- */
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:wght@300;400;500;600&display=swap&font-display=swap');

/* --- Design tokens ----------------------------------------- */
:root {
    --primary:      #1a1a2e;
    --accent:       #e94560;
    --accent2:      #0f3460;
    --gold:         #f5a623;
    --success:      #2ecc71;
    --danger:       #e74c3c;
    --text:         #1a1a2e;
    --text-muted:   #888;
    --bg:           #f8f8fc;
    --white:        #ffffff;
    --border:       rgba(0,0,0,0.08);
    --radius:       16px;
    --radius-sm:    10px;
    --shadow:       0 8px 32px rgba(26,26,46,0.12);
    --mono:         'Space Mono', monospace;
    --sans:         'DM Sans', sans-serif;
}

/* --- Reset -------------------------------------------------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- Base --------------------------------------------------- */
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    /* Prevent iOS bounce from shifting fixed elements */
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
  
}

/* ============================================================
   HOME PAGE
   ============================================================ */
body.home-page {
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
   
}

body.home-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(233,69,96,0.15) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    animation: pulse 4s ease-in-out infinite;
    pointer-events: none;
    will-change: transform, opacity;
    
}

body.home-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    animation: pulse 6s ease-in-out infinite reverse;
    pointer-events: none;
    will-change: transform, opacity;
}

@keyframes pulse {
    0%, 100% { transform: scale(1);   opacity: .7; }
    50%       { transform: scale(1.1); opacity: 1;  }
}

.home-wrap {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
   
}

.home-logo { text-align: center; }

.logo-img {
    width: 300px;
    height: 200px;
    object-fit: cover;
}

.logo-text {
    font-family: var(--mono);
    font-size: 52px;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -1px;
}

/* Generate button */
.generate-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 48px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 100px;
    font-family: var(--sans);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1),
                box-shadow .3s ease;
    box-shadow: 0 0 0 0 rgba(233,69,96,0.4);
    position: relative;
    overflow: hidden;
    will-change: transform;
}

.generate-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    opacity: 0;
    transition: opacity .3s;
}

.generate-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 20px 60px rgba(233,69,96,0.4);
}
.generate-btn:hover::before { opacity: 1; }
.generate-btn:active         { transform: scale(0.97); }
.generate-btn.loading        { opacity: .7; pointer-events: none; }

.btn-icon { font-size: 22px; }

/* Link result */
.link-result {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    animation: fadeUp .4s ease;
}

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

.generated-link {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    font-family: var(--mono);
    font-size: 13px;
    color: rgba(255,255,255,0.9);
    word-break: break-all;
    text-align: center;
    width: 100%;
    user-select: all;
}

.link-timer       { font-size: 13px; color: rgba(255,255,255,0.5); }
.link-timer strong { color: var(--gold); }

.copy-btn {
    padding: 12px 28px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 100px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .2s;
    font-family: var(--sans);
}
.copy-btn:hover { background: rgba(255,255,255,0.2); }

.share-hint {
    font-size: 12px;
    color: rgba(255,255,255,0.4);
    text-align: center;
}

/* ============================================================
   SETUP SCREEN
   ============================================================ */
.screen { min-height: 100vh; }

.setup-wrap {
    max-width: 480px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
}

.setup-logo {
    font-family: var(--mono);
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin-bottom: 1.5rem;
    padding-top: 1rem;
}

/* Step dots */
.steps {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 2rem;
}
.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: width .3s, background .3s, border-radius .3s;
}
.step-dot.active { background: var(--accent); width: 24px; border-radius: 4px; }
.step-dot.done   { background: var(--success); }

.step-panel { animation: fadeUp .3s ease; }

.step-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}
.step-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* Info card */
.info-card {
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 1rem;
    margin-bottom: 1.5rem;
}
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--accent2); }

/* Password inputs */
.pw-group { margin-bottom: 1.25rem; }
.pw-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pw-group input {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    font-size: 15px;
    font-family: var(--sans);
    color: var(--text);
    background: var(--white);
    outline: none;
    transition: border-color .2s;
    /* Prevent zoom on iOS (font-size < 16px triggers auto-zoom) */
    font-size: 16px;
}
.pw-group input:focus { border-color: var(--accent); }

.pw-preview {
    margin-top: 8px;
    font-family: var(--mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--accent2);
    letter-spacing: 3px;
    text-align: center;
    padding: 12px;
    background: rgba(15,52,96,0.06);
    border-radius: var(--radius-sm);
    min-height: 48px;
}

.security-note {
    font-size: 13px;
    color: var(--success);
    background: rgba(46,204,113,0.08);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    border: 1px solid rgba(46,204,113,0.2);
}

.action-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    font-family: var(--sans);
    cursor: pointer;
    transition: background .2s, transform .2s;
}
.action-btn:hover  { background: var(--accent2); transform: translateY(-1px); }
.action-btn:active { transform: scale(0.98); }

.error-msg {
    padding: 10px 14px;
    background: rgba(231,76,60,0.08);
    color: var(--danger);
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 1rem;
    border: 1px solid rgba(231,76,60,0.2);
}

/* ============================================================
   CHAT SCREEN — fixed layout, full-height, no overflow bugs
   ============================================================ */
#chatScreen {
    position: fixed;
    inset: 0;            /* top:0 right:0 bottom:0 left:0 */
    display: none;       /* shown by JS via openChat() */
}
 
/* flex column that fills #chatScreen */

 
/* --- Header ------------------------------------------------- */
.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--white);
    flex-shrink: 0;       /* never compress */
    z-index: 10;
}
 
.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;              /* push action buttons to the right */
    min-width: 0;         /* allow text truncation */
}
 
.partner-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}
 
.partner-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.partner-status { font-size: 11px; color: var(--text-muted); }
.partner-status.online { color: var(--success); }
 
/* All header action buttons sit in a single flex row */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
 
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: background .15s;
    flex-shrink: 0;
}
.icon-btn:hover  { background: var(--bg); }
.icon-btn.danger { color: var(--danger); }
 
/* --- Security bar ------------------------------------------ */
.security-bar {
    padding: 5px;
    background: rgba(46,204,113,0.07);
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--success);
    border-bottom: 1px solid rgba(46,204,113,0.15);
    flex-shrink: 0;
}
 
/* --- Messages list ----------------------------------------- */

 
.msg-wrap {
    display: flex;
    width: 100%;
    margin: 4px 0;
}

.msg-wrap.mine {
    justify-content: flex-end;
}

.msg-wrap.theirs {
    justify-content: flex-start;
}
 
.msg-bubble {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: break-word;
    
}
.msg-bubble.mine {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
    font-style: italic;
    font-weight: 400;
}

/* receiver */
.msg-bubble.theirs {
    background: var(--white);
    color: var(--text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
    font-style: normal;
    font-weight: 700;
}
.msg-bubble img {
    max-width: 100%;
    border-radius: 10px;
    display: block;
}
 
.msg-time {
    font-size: 10px;
    opacity: .5;
    margin-top: 3px;
    display: block;
}
 
.sys-msg {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 12px;
    background: rgba(0,0,0,0.04);
    border-radius: 20px;
    align-self: center;
}
 
/* Typing indicator */
.typing-wrap {
    display: flex;
    gap: 4px;
    padding: 6px 14px;
    align-items: center;
    flex-shrink: 0;
}
.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
 
@keyframes typingBounce {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30%            { opacity: 1;  transform: translateY(-4px); }
}
 
/* Image preview bar */
.img-preview-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.img-preview-bar img {
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
}
.img-preview-bar button {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
 
/* --- Input bar --------------------------------------------- */
/*
   FIXED: removed the rogue `margin-top:100px` from .msg-input
   and made the whole bar a proper sticky bottom row.
*/

 
.attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: background .15s;
}
.attach-btn:hover { background: #eee; }
 
.msg-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 22px;
    border: 1.5px solid var(--border);
    /* FIXED: was 16px minimum to prevent iOS auto-zoom */
    font-size: 16px;
    font-family: var(--sans);
    color: var(--text);
    background: var(--bg);
    outline: none;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color .2s;
    /* FIXED: removed margin-top:100px that was hiding the input */
    margin-top: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.msg-input:focus { border-color: var(--accent2); }
 
.send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s, transform .2s;
    will-change: transform;
}
.send-btn:hover  { background: #c73652; transform: scale(1.07); }
.send-btn:active { transform: scale(0.93); }
 
/* ============================================================
   VOICE CALL OVERLAY
   ============================================================ */
.call-overlay {
    position: fixed;
    inset: 0;
    background: var(--primary);
    color: #fff;
    display: flex;           /* shown/hidden by JS */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 200;            /* above everything */
}

.call-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    font-weight: 700;
}
.call-name       { font-size: 22px; font-weight: 600; }
.call-status     { font-size: 14px; opacity: .7; }
.call-voice-note { font-size: 13px; opacity: .5; }

.call-btns { display: flex; gap: 20px; margin-top: 16px; }

.call-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s;
}
.call-btn:active { transform: scale(0.9); }
.call-btn.mute   { background: rgba(255,255,255,0.15); }
.call-btn.end    { background: var(--danger); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
    .setup-wrap    { padding: 1.25rem 1rem; }
    .generate-btn  { padding: 16px 32px; font-size: 16px; }
    .msg-bubble    { max-width: 88%; }
    .chat-header   { padding: 8px 10px; }
    .icon-btn      { width: 32px; height: 32px; font-size: 14px; }
}

/* Very small screens (320px) */
@media (max-width: 360px) {
    .generate-btn { padding: 14px 24px; font-size: 15px; }
    .logo-img     { width: 220px; height: 140px; }
}