/* Tome Management Panel - Base Styles */

:root {
    --primary: #5865F2;
    --primary-dark: #4752C4;
    --bg: #1E1F22;
    --bg-card: #2B2D31;
    --bg-nav: #111214;
    --text: #DBDEE1;
    --text-muted: #949BA4;
    --border: #3F4147;
    --success: #3BA55C;
    --error: #ED4245;
    --warning: #FAA61A;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.navbar {
    background-color: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 1rem;
}

.navbar-brand a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.navbar-icon {
    display: block;
    border-radius: 6px;
}

.navbar-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    margin-left: 2rem;
}

.navbar-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.navbar-links a:hover {
    color: var(--text);
}

/* Navbar user section */
.navbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.user-avatar {
    border-radius: 50%;
    flex-shrink: 0;
}

.user-name {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-logout:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(237, 66, 69, 0.1);
}

/* Main Container */
.container {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* Dashboard / Server Selection */
.dashboard h1 {
    margin-bottom: 0.5rem;
}

.dashboard-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.guild-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.guild-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s, background 0.2s;
}

.guild-card:hover {
    border-color: var(--primary);
    background: rgba(88, 101, 242, 0.05);
}

.guild-card-icon {
    border-radius: 50%;
    flex-shrink: 0;
}

.guild-card-icon-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.guild-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.guild-card-name {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.guild-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.guild-icon {
    border-radius: 50%;
    flex-shrink: 0;
}

.guild-info h1 {
    margin-bottom: 0;
    font-size: 1.4rem;
}

/* Tags Grid */
.tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1rem;
}

.tag-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tag-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-nav);
}

.tag-card-header h3 {
    font-size: 1rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tag-card-header h3 code {
    font-size: 0.95rem;
}

.tag-card-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.tag-card-body {
    padding: 0.75rem 1rem;
    flex: 1;
}

.tag-content-preview {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    word-break: break-word;
}

.tag-aliases {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.75rem;
    align-items: center;
}

.alias-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.alias-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: rgba(88, 101, 242, 0.15);
    color: var(--primary);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.tag-card-footer {
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Tags Filter Bar */
.tags-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.tag-filter-input {
    flex: 1;
    max-width: 420px;
    padding: 0.55rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.tag-filter-input::placeholder {
    color: var(--text-muted);
}

.tag-filter-input:focus {
    outline: none;
    border-color: var(--primary);
}

.tag-filter-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1.5;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn-primary {
    background: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
}

.btn-danger {
    background: var(--error);
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.inline-form {
    display: inline;
}

/* Tag Form */
.tag-form-page {
    max-width: 800px;
}

.tag-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Alert */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(237, 66, 69, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

.alert-success {
    background: rgba(59, 165, 92, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

/* Code */
code {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* Page Headers */
h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* ──────────────────────────────────────────────
   Guild Settings Page
   ────────────────────────────────────────────── */

.settings-page {
    max-width: 800px;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.settings-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-nav);
}

.settings-card-header h2 {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
}

.settings-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.settings-card-body {
    padding: 1.5rem;
}

/* ──────────────────────────────────────────────
   Role Autocomplete & Bubble Component
   ────────────────────────────────────────────── */

.role-autocomplete-wrapper {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.4rem 0.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    min-height: 42px;
    cursor: text;
    transition: border-color 0.2s;
}

.role-autocomplete-wrapper:focus-within {
    border-color: var(--primary);
}

.role-bubbles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.role-bubble {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.25rem 0.2rem 0.6rem;
    background: rgba(88, 101, 242, 0.18);
    color: var(--primary);
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    animation: bubbleIn 0.15s ease-out;
}

@keyframes bubbleIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.role-bubble-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: none;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.role-bubble-remove:hover {
    background: var(--error);
    color: #fff;
}

.role-search-input {
    flex: 1;
    min-width: 140px;
    border: none !important;
    background: transparent !important;
    color: var(--text) !important;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.15rem 0.25rem !important;
    outline: none;
    width: auto;
}

.role-search-input::placeholder {
    color: var(--text-muted);
}

/* Autocomplete Dropdown */
.role-autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.role-autocomplete-dropdown.active {
    display: block;
}

.role-dropdown-item {
    padding: 0.55rem 0.75rem;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text);
    transition: background 0.1s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.role-dropdown-item:first-child {
    border-radius: 6px 6px 0 0;
}

.role-dropdown-item:last-child {
    border-radius: 0 0 6px 6px;
}

.role-dropdown-item:hover,
.role-dropdown-item.active {
    background: rgba(88, 101, 242, 0.12);
}

.role-dropdown-item.selected {
    color: var(--text-muted);
    cursor: default;
    background: transparent;
}

.role-dropdown-item.selected::after {
    content: '✓ Added';
    font-size: 0.75rem;
    color: var(--success);
}

.role-dropdown-no-results {
    padding: 0.75rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Save Status */
.save-status {
    font-size: 0.85rem;
    align-self: center;
    margin-left: 0.5rem;
}

.save-status.success {
    color: var(--success);
}

.save-status.error {
    color: var(--error);
}

/* Delete Confirmation Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    margin: 0;
}

.modal-body {
    padding: 1.25rem;
}

.modal-body p {
    margin-bottom: 0.5rem;
}

.modal-warning {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}