/* ============================================================
   FFTags — Dark theme inspired by FFXIV's aesthetic
   ============================================================ */

:root {
    --bg: #0b0f1c;
    --bg-card: #141826;
    --bg-card-hover: #1a2035;
    --border: #2a3050;
    --gold: #c8a84b;
    --gold-light: #e0c070;
    --blue: #5b8fd4;
    --blue-light: #7aaae8;
    --text: #ddd8cc;
    --text-muted: #7a8099;
    --text-dim: #4a5070;
    --success: #4caf7d;
    --error: #e05a5a;
    --discord: #5865f2;
    --discord-hover: #4752c4;
    --radius: 8px;
    --radius-sm: 4px;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--blue-light);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ============================================================
   Navbar
   ============================================================ */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
    background: #0d1120;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gold);
    text-decoration: none;
    letter-spacing: 0.02em;
}
.navbar-brand:hover { color: var(--gold-light); text-decoration: none; }

.brand-crystal {
    color: var(--gold);
    margin-right: 0.3rem;
}

.beta-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--bg);
    background: var(--gold);
    border-radius: 3px;
    padding: 1px 5px;
    margin-left: 0.35rem;
    vertical-align: middle;
    line-height: 1.6;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
}

.username {
    font-size: 0.9rem;
    color: var(--text);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, opacity 0.15s;
    text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--gold);
    color: #0b0f1c;
}
.btn-primary:hover:not(:disabled) { background: var(--gold-light); text-decoration: none; color: #0b0f1c; }

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-card); color: var(--text); text-decoration: none; }

.btn-discord {
    background: var(--discord);
    color: #fff;
}
.btn-discord:hover { background: var(--discord-hover); text-decoration: none; color: #fff; }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; padding: 0.65rem 1rem; }

.discord-icon {
    width: 18px;
    height: 18px;
}

/* ============================================================
   Flash messages
   ============================================================ */

.flash-container {
    max-width: 720px;
    margin: 1rem auto 0;
    padding: 0 1.5rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.flash-success { background: rgba(76, 175, 125, 0.15); border: 1px solid rgba(76, 175, 125, 0.4); color: var(--success); }
.flash-error   { background: rgba(224, 90, 90, 0.15);  border: 1px solid rgba(224, 90, 90, 0.4);  color: var(--error); }

/* ============================================================
   Main layout
   ============================================================ */

.main-content {
    flex: 1;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

/* ============================================================
   Hero
   ============================================================ */

.hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.hero-title {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
}

/* ============================================================
   Search card
   ============================================================ */

.search-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 2.5rem;
}

.search-form {
    padding: 1.5rem;
}

.form-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}
.form-group:last-child { margin-bottom: 0; }

.flex-1 { flex: 1; min-width: 80px; }
.flex-2 { flex: 2; min-width: 140px; }

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="search"],
select {
    background: #0d1120;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    padding: 0.6rem 0.8rem;
    outline: none;
    width: 100%;
    transition: border-color 0.15s;
}
input:focus, select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(200, 168, 75, 0.15);
}
input::placeholder { color: var(--text-dim); }

select option { background: #0d1120; }

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}
.form-hint code {
    background: rgba(255,255,255,0.06);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.78rem;
}

/* ============================================================
   Search input + suggestions
   ============================================================ */

.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    color: var(--text-dim);
    font-size: 1.1rem;
    pointer-events: none;
    transform: scaleX(-1); /* flip the magnifier to face right */
    line-height: 1;
}

.search-input-wrap input[type="text"] {
    flex: 1;
    padding-left: 2.4rem;
    font-size: 1rem;
    height: 46px;
}

.search-btn {
    flex-shrink: 0;
    height: 46px;
    padding: 0 1.25rem;
    font-size: 0.95rem;
}

.search-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.suggestions {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #1a2035;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    z-index: 200;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.suggestions.open { display: block; }

.suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    gap: 0.75rem;
    transition: background 0.1s;
}
.suggestion-item:hover,
.suggestion-item.active {
    background: rgba(200, 168, 75, 0.1);
}

.sug-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.sug-server {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.sug-region {
    background: rgba(91, 143, 212, 0.2);
    color: var(--blue-light);
    border: 1px solid rgba(91, 143, 212, 0.35);
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.05rem 0.35rem;
    letter-spacing: 0.05em;
}

/* ============================================================
   Info cards
   ============================================================ */

.info-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.info-icon {
    font-size: 1.5rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.info-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.info-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ============================================================
   Character page
   ============================================================ */

.character-header {
    margin-bottom: 2rem;
}

.inline-search {
    margin-bottom: 1.25rem;
}

.inline-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.inline-search-wrap input[type="text"] {
    flex: 1;
    padding-left: 2.4rem;
    height: 38px;
    font-size: 0.9rem;
}

.inline-search-wrap .search-btn {
    height: 38px;
    padding: 0 1rem;
    font-size: 0.875rem;
}

.character-name {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.02em;
}

.character-server {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.region-badge {
    background: rgba(91, 143, 212, 0.2);
    color: var(--blue-light);
    border: 1px solid rgba(91, 143, 212, 0.4);
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    letter-spacing: 0.05em;
}

.lodestone-link {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ============================================================
   Tags section
   ============================================================ */

.tags-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.tags-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.tags-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tag-count {
    background: rgba(200, 168, 75, 0.15);
    color: var(--gold);
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
}

.login-prompt {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============================================================
   Tag pills (colored)
   ============================================================ */

.tag-pill {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 99px;
    background: color-mix(in srgb, var(--tag-color, #5b8fd4) 18%, transparent);
    border: 1.5px solid var(--tag-color, #5b8fd4);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    position: relative;
    cursor: default;
}

/* JS-driven cursor-following tooltip */
#fftip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    background: #1a2035;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    max-width: 280px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    display: none;
}
#fftip .fftip-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.95rem;
    font-weight: 400;
    margin-bottom: 0.4rem;
    line-height: 1.2;
}
#fftip .fftip-body {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

/* Tags grid layout */
.tags-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    min-height: 2rem;
}

.tag-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.tag-vote-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.vote-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.65rem;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.vote-btn:hover:not(:disabled) {
    background: rgba(200, 168, 75, 0.15);
    border-color: var(--gold);
    color: var(--gold);
}
.vote-btn.voted {
    background: rgba(200, 168, 75, 0.2);
    border-color: var(--gold);
    color: var(--gold);
}
.vote-btn:disabled { cursor: not-allowed; opacity: 0.45; }

.vote-count {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 1ch;
}

.no-tags {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 1.5rem 0;
}

/* ============================================================
   Add tag section (available pills picker)
   ============================================================ */

.below-threshold-section {
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
    margin-top: 1.25rem;
}

.below-threshold-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.below-card {
    opacity: 0.45;
    transition: opacity 0.2s;
}

.below-card:hover {
    opacity: 0.75;
}

.add-tag-section {
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
}

.add-tag-heading {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.available-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.available-pill {
    opacity: 0.45;
    cursor: pointer;
    border: 1.5px dashed var(--tag-color, #5b8fd4);
    background: transparent;
    transition: opacity 0.15s, background 0.15s;
}
.available-pill:hover:not(:disabled) {
    opacity: 1;
    background: color-mix(in srgb, var(--tag-color, #5b8fd4) 18%, transparent);
}
.available-pill:disabled { cursor: not-allowed; opacity: 0.2; }

.tag-error {
    font-size: 0.82rem;
    color: var(--error);
    margin-top: 0.4rem;
}

/* ============================================================
   Admin page
   ============================================================ */

.admin-header {
    margin-bottom: 2rem;
}

.admin-title {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--gold);
}

.admin-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.admin-section {
    margin-bottom: 2.5rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.admin-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.admin-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.tag-def-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.tag-def-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.tag-def-row:last-child { border-bottom: none; }

.tag-def-pill { cursor: default; }

.tag-def-tooltip {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-def-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.tag-def-edit-form {
    padding: 1rem;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border);
}

.edit-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.preview-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.color-input {
    padding: 0.2rem;
    height: 38px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.btn-danger {
    background: rgba(224, 90, 90, 0.15);
    color: var(--error);
    border: 1px solid rgba(224, 90, 90, 0.4);
}
.btn-danger:hover { background: rgba(224, 90, 90, 0.25); text-decoration: none; color: var(--error); }

.mod-id code {
    font-size: 0.85rem;
    color: var(--text);
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
}
.footer a { color: var(--text-muted); }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 600px) {
    .navbar { padding: 0 1rem; }
    .main-content { padding: 1.5rem 1rem; }
    .hero-title { font-size: 1.6rem; }
    .info-section { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .tag-input-row { flex-direction: column; }
    .tags-header { flex-direction: column; align-items: flex-start; }
}
