/* ==========================================
   Albion Build Party — Design System
   Minimalist dark theme with subtle animations
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
    --bg-0: #08080d;
    --bg-1: #0e0e16;
    --bg-2: #14141f;
    --bg-3: #1a1a28;
    --bg-hover: #1f1f30;
    --text-1: #e8e8ed;
    --text-2: #9898a8;
    --text-3: #5c5c6e;
    --accent: #6366f1;
    --accent-soft: rgba(99, 102, 241, 0.12);
    --accent-glow: rgba(99, 102, 241, 0.25);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
    --transition: 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --font: 'Inter', -apple-system, sans-serif;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg-0);
    color: var(--text-1);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

/* --- Layout --- */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.container { max-width: 960px; margin: 0 auto; padding: 0 24px; width: 100%; }

/* --- Top bar --- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 8, 13, 0.8);
    backdrop-filter: blur(12px);
    position: sticky; top: 0; z-index: 100;
}
.topbar-brand {
    font-weight: 600; font-size: 1.05rem; color: var(--text-1);
    display: flex; align-items: center; gap: 8px;
}
.topbar-brand span { color: var(--accent); }
.topbar-user {
    display: flex; align-items: center; gap: 12px;
}
.topbar-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    border: 2px solid var(--border);
}
.topbar-name { font-size: 0.9rem; color: var(--text-2); }
.topbar-logout {
    font-size: 0.8rem; color: var(--text-3);
    transition: color var(--transition);
    cursor: pointer; background: none; border: none;
}
.topbar-logout:hover { color: var(--danger); }

/* --- Login page --- */
.login-wrapper {
    flex: 1; display: flex; align-items: center; justify-content: center;
}
.login-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    max-width: 400px; width: 100%;
    animation: fadeUp 0.5s ease;
}
.login-card h1 {
    font-size: 1.5rem; font-weight: 600; margin-bottom: 8px;
}
.login-card p {
    color: var(--text-2); font-size: 0.9rem; margin-bottom: 32px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem; font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    position: relative; overflow: hidden;
}
.btn::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.08), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}
.btn:hover::after { opacity: 1; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-discord {
    background: #5865F2; color: #fff;
    padding: 14px 28px; font-size: 1rem;
    box-shadow: 0 0 0 0 rgba(88, 101, 242, 0.3);
}
.btn-discord:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(88, 101, 242, 0.35);
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-3);
    border-color: var(--border-hover);
    color: var(--text-1);
}

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon {
    padding: 6px; border-radius: 8px;
    background: transparent; border: 1px solid var(--border);
    color: var(--text-3); cursor: pointer;
    transition: all var(--transition);
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
}
.btn-icon:hover { background: var(--bg-3); color: var(--text-1); border-color: var(--border-hover); }
.btn-icon.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: rgba(239,68,68,0.3); }

/* --- Dashboard --- */
.dashboard { padding: 40px 0; flex: 1; }
.section-title {
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 16px;
}

/* Guild selector */
.guild-tabs {
    display: flex; gap: 6px; margin-bottom: 32px;
    overflow-x: auto; padding-bottom: 4px;
}
.guild-tab {
    padding: 8px 16px;
    border-radius: var(--radius);
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.85rem; font-weight: 500;
    cursor: pointer; white-space: nowrap;
    transition: all var(--transition);
}
.guild-tab:hover { background: var(--bg-3); color: var(--text-1); }
.guild-tab.active {
    background: var(--accent-soft);
    border-color: rgba(99, 102, 241, 0.3);
    color: var(--accent);
}

/* Template grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.template-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition);
    animation: fadeUp 0.4s ease;
}
.template-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.template-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.template-name { font-weight: 600; font-size: 1rem; }
.template-slots {
    font-size: 0.75rem; color: var(--text-3);
    background: var(--bg-3); padding: 2px 8px;
    border-radius: 20px;
}
.template-roles {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 16px;
}
.role-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    background: var(--bg-3);
    border-radius: 20px;
    font-size: 0.78rem; color: var(--text-2);
}
.template-actions {
    display: flex; gap: 8px; justify-content: flex-end;
    padding-top: 12px; border-top: 1px solid var(--border);
}

/* New template card */
.template-card-new {
    background: transparent;
    border: 2px dashed var(--border);
    display: flex; align-items: center; justify-content: center;
    min-height: 180px; cursor: pointer;
    transition: all var(--transition);
}
.template-card-new:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.template-card-new span {
    color: var(--text-3); font-size: 0.9rem;
    transition: color var(--transition);
}
.template-card-new:hover span { color: var(--accent); }

/* --- Builder --- */
.builder { padding: 40px 0; flex: 1; }
.builder-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 32px;
}
.builder-title-input {
    font-size: 1.4rem; font-weight: 600;
    background: transparent; border: none; outline: none;
    color: var(--text-1); width: 100%;
    border-bottom: 2px solid transparent;
    padding-bottom: 4px;
    transition: border-color var(--transition);
}
.builder-title-input:focus { border-color: var(--accent); }
.builder-title-input::placeholder { color: var(--text-3); }

.builder-counter {
    font-size: 0.85rem; color: var(--text-2);
    background: var(--bg-2); padding: 6px 14px;
    border-radius: 20px; border: 1px solid var(--border);
    white-space: nowrap;
}
.builder-counter.over { color: var(--danger); border-color: rgba(239,68,68,0.3); }
.builder-counter.full { color: var(--success); border-color: rgba(34,197,94,0.3); }

/* Role rows */
.roles-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.role-row {
    display: grid;
    grid-template-columns: 48px 1fr 140px 100px 40px;
    align-items: center; gap: 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    transition: all var(--transition);
    animation: fadeUp 0.3s ease;
}
.role-row:hover { border-color: var(--border-hover); }

.role-emoji-input {
    width: 40px; text-align: center; font-size: 1.2rem;
    background: var(--bg-3); border: 1px solid var(--border);
    border-radius: 8px; padding: 6px; cursor: text;
    transition: border-color var(--transition);
    outline: none;
}
.role-emoji-input:focus { border-color: var(--accent); }

.role-name-input {
    background: transparent; border: none; outline: none;
    color: var(--text-1); font-size: 0.9rem;
    font-family: var(--font);
    width: 100%;
}
.role-name-input::placeholder { color: var(--text-3); }

.role-category-select {
    background: var(--bg-3); border: 1px solid var(--border);
    border-radius: 8px; padding: 6px 10px;
    color: var(--text-2); font-size: 0.8rem;
    font-family: var(--font);
    outline: none; cursor: pointer;
    transition: border-color var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235c5c6e' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}
.role-category-select:focus { border-color: var(--accent); }

.role-qty {
    display: flex; align-items: center; gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden;
}
.role-qty button {
    background: var(--bg-3); border: none;
    color: var(--text-2); width: 30px; height: 30px;
    cursor: pointer; font-size: 1rem;
    transition: all var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.role-qty button:hover { background: var(--bg-hover); color: var(--text-1); }
.role-qty-val {
    width: 36px; text-align: center;
    font-size: 0.85rem; font-weight: 600;
    background: var(--bg-2); color: var(--text-1);
    border: none; outline: none;
    font-family: var(--font);
}

.role-delete {
    background: transparent; border: none;
    color: var(--text-3); cursor: pointer;
    font-size: 1.1rem; padding: 4px;
    transition: color var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.role-delete:hover { color: var(--danger); }

.add-role-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-3);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}
.add-role-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.builder-actions {
    display: flex; gap: 12px; justify-content: flex-end;
    padding-top: 24px; margin-top: 8px;
    border-top: 1px solid var(--border);
}

/* --- Feedback / Toast --- */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
    z-index: 999;
}
.toast.success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.toast.error { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }

/* --- Empty state --- */
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-3);
}
.empty-state p { margin-top: 8px; font-size: 0.9rem; }

/* --- Loading --- */
.loading {
    display: flex; align-items: center; justify-content: center;
    padding: 60px; color: var(--text-3);
}
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 10px;
}

/* --- Animations --- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Responsive --- */
@media (max-width: 640px) {
    .topbar { padding: 12px 16px; }
    .container { padding: 0 16px; }
    .login-card { padding: 32px 24px; }
    .role-row {
        grid-template-columns: 40px 1fr 40px;
        gap: 8px;
    }
    .role-category-select,
    .role-qty { display: none; }
    .templates-grid { grid-template-columns: 1fr; }
}
