/* LinkVault AI — Extension Popup */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:       #0f172a;
    --bg2:      #1e293b;
    --bg3:      #334155;
    --border:   #334155;
    --text:     #f1f5f9;
    --muted:    #94a3b8;
    --primary:  #6366f1;
    --primary-h:#818cf8;
    --success:  #10b981;
    --error:    #ef4444;
    --radius:   8px;
    --font:     'Inter', system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg:     #f8fafc;
        --bg2:    #ffffff;
        --bg3:    #e2e8f0;
        --border: #cbd5e1;
        --text:   #0f172a;
        --muted:  #64748b;
    }
}

html { width: 340px; }

body {
    width: 340px;
    min-height: 120px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.5;
}

.screen { width: 100%; }
.hidden { display: none !important; }

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.user-name {
    font-size: 11px;
    color: var(--muted);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color .15s;
}
.icon-btn:hover { color: var(--error); }

/* Duplicate banner */
.duplicate-banner {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: rgba(16, 185, 129, .12);
    border-bottom: 1px solid rgba(16, 185, 129, .25);
    font-size: 12px;
    color: var(--success);
}
.duplicate-banner a { color: var(--success); font-weight: 600; text-decoration: underline; }

/* Form */
.form-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.field-row { display: flex; align-items: center; gap: 8px; }
.field-row-half { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.favicon { width: 16px; height: 16px; border-radius: 3px; flex-shrink: 0; }
.url-info { flex: 1; min-width: 0; }
.domain { font-weight: 600; font-size: 12px; color: var(--text); }
.url-truncate { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

input[type="text"],
input[type="url"],
input[type="password"],
textarea,
select {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 12px;
    padding: 6px 8px;
    width: 100%;
    transition: border-color .15s;
    outline: none;
    resize: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }

select { appearance: none; cursor: pointer; }

.field-hint { font-size: 11px; color: var(--primary); text-decoration: none; margin-top: 2px; }
.field-hint:hover { text-decoration: underline; }

/* Tags */
.tags-container {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    position: relative;
}
.tags-container:focus-within { border-color: var(--primary); }

.selected-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 2px; }

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(99, 102, 241, .15);
    color: var(--primary-h);
    border: 1px solid rgba(99, 102, 241, .3);
    cursor: pointer;
}
.tag-chip:hover { background: rgba(239, 68, 68, .15); color: var(--error); border-color: rgba(239, 68, 68, .3); }

#tag-input {
    border: none;
    background: transparent;
    padding: 3px 4px;
    font-size: 12px;
    width: 100%;
}
#tag-input:focus { border: none; }

.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 140px;
    overflow-y: auto;
}

.tag-option {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: background .1s;
}
.tag-option:hover, .tag-option.active { background: var(--bg3); }

.tag-create {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--primary-h);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 5px;
}
.tag-create:hover { background: var(--bg3); }

/* Actions */
.actions {
    display: flex;
    gap: 8px;
    padding-top: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: var(--font);
    transition: opacity .15s, transform .1s;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; flex: 1; justify-content: center; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }

.btn-secondary {
    background: var(--bg2);
    color: var(--text);
    border: 1px solid var(--border);
    flex: 1;
    justify-content: center;
}
.btn-secondary:hover:not(:disabled) { background: var(--bg3); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 11px; }

/* Setup screen */
.setup-body {
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.setup-hint { font-size: 12px; color: var(--muted); }

/* Error */
.error {
    padding: 7px 10px;
    border-radius: var(--radius);
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .3);
    color: var(--error);
    font-size: 12px;
}

/* Success screen */
.success-body {
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}
.success-icon {
    width: 52px;
    height: 52px;
    background: rgba(16, 185, 129, .15);
    border: 2px solid rgba(16, 185, 129, .4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--success);
}
.success-msg { font-size: 15px; font-weight: 700; color: var(--text); }
.success-sub { font-size: 12px; color: var(--muted); }
