/* BlitzForms — shared chrome: tokens, top bar, sidebar, footer, toasts, dialogs.
   Page-specific rules live in the page's own .css (auto-loaded per endpoint). */

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --bg-color: #f3f5f9;
    --text-color: #1a202c;
    --muted-color: #718096;
    --header-height: 80px;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 90px;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --soft-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    --danger-color: #dc2626;
}

/* Elements toggled with the `hidden` attribute must stay hidden even when a class sets display. */
[hidden] { display: none !important; }

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Roboto, sans-serif;
    overflow-x: hidden;
    padding-top: var(--header-height);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.5s ease-out forwards; }

/* ---------- Top bar ---------- */
.glass-header {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: var(--header-height);
    z-index: 1050;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: var(--glass-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
}
.header-container {
    width: 100%;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.brand-link { display: flex; align-items: center; text-decoration: none; height: 100%; }
.brand-logo-img {
    max-height: 42px;
    width: auto;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.brand-link:hover .brand-logo-img { transform: scale(1.05); }

.header-actions { display: flex; align-items: center; gap: 1.5rem; }
.header-username { font-weight: 600; color: var(--muted-color); }

.btn-circle-action {
    width: 45px; height: 45px; border-radius: 50%;
    background: white; border: 1px solid #e2e8f0;
    display: flex; align-items: center; justify-content: center;
    color: #64748b; font-size: 1.2rem; text-decoration: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.btn-circle-action:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(118, 75, 162, 0.25);
    background: var(--primary-gradient); border-color: transparent; color: white;
}
.btn-pill-action {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 24px; background: var(--primary-gradient);
    border-radius: 50px; color: white; text-decoration: none;
    font-weight: 600; font-size: 0.95rem;
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.3);
    transition: all 0.3s ease;
}
.btn-pill-action:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(118, 75, 162, 0.4); color: white; }

.header-toggle-btn {
    background: transparent; border: none; font-size: 1.5rem;
    color: #64748b; margin-right: 15px; display: none;
}

/* ---------- Sidebar + content ---------- */
.wrapper { display: flex; width: 100%; flex: 1; }

.sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    position: fixed;
    top: var(--header-height);
    left: 0;
    z-index: 1040;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: var(--glass-border);
    display: flex; flex-direction: column;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 1.5rem 1rem;
}
.sidebar.collapsed {
    min-width: var(--sidebar-collapsed-width);
    max-width: var(--sidebar-collapsed-width);
    padding: 1.5rem 0.5rem;
}
.sidebar-toggle-internal { width: 100%; display: flex; justify-content: flex-end; margin-bottom: 1rem; }
.sidebar-toggle-internal button {
    background: rgba(0, 0, 0, 0.04); border: none; border-radius: 8px;
    width: 32px; height: 32px; color: var(--muted-color); transition: all 0.2s;
}
.sidebar-toggle-internal button:hover { color: var(--primary-color); background: rgba(0, 0, 0, 0.08); }

.sidebar .nav-link {
    display: flex; align-items: center; padding: 14px 16px;
    color: var(--muted-color); border-radius: 16px; margin-bottom: 8px;
    transition: all 0.3s ease; font-weight: 500;
    white-space: nowrap; overflow: hidden;
}
.sidebar .nav-link:hover {
    background-color: white; color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05); transform: translateX(4px);
}
.sidebar .nav-link.active {
    background: var(--primary-gradient); color: white;
    box-shadow: 0 8px 20px rgba(118, 75, 162, 0.4);
}
.sidebar .nav-link i { font-size: 1.3rem; min-width: 24px; display: flex; justify-content: center; }
.link-text { margin-left: 14px; transition: opacity 0.3s; }
.sidebar.collapsed .link-text { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 14px 0; }

.sidebar-footer { margin-top: auto; }
.user-profile {
    display: flex; align-items: center; padding: 10px;
    border-radius: 16px; background: white;
    border: 1px solid rgba(0, 0, 0, 0.04); cursor: pointer; transition: all 0.3s;
}
.user-profile:hover { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08); transform: translateY(-2px); }
.user-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary-gradient); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0;
}
.user-info { margin-left: 12px; overflow: hidden; }
.user-name { font-weight: 700; font-size: 0.9rem; color: #2d3748; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: #a0aec0; }
.user-menu { border-radius: 12px; }
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed .user-profile { justify-content: center; background: transparent; border: none; }

#content {
    flex: 1;
    min-width: 0; /* a flex item never shrinks below its content; wide grids must scroll inside, not clip the page */
    padding: 2rem 3rem;
    max-width: 100%;
    transition: margin-left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.wrapper.with-sidebar #content { margin-left: var(--sidebar-width); }
body.sidebar-is-collapsed .wrapper.with-sidebar #content { margin-left: var(--sidebar-collapsed-width); }

.content-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; gap: 1rem; flex-wrap: wrap; }
.page-title { font-weight: 800; font-size: 1.75rem; color: var(--text-color); letter-spacing: -0.5px; margin: 0; }
.page-subtitle { color: var(--muted-color); margin: 0.25rem 0 0; }

.btn-primary { background: var(--primary-gradient); border: none; }
.btn-primary:hover { background: var(--primary-gradient); filter: brightness(1.05); }

.loading-spinner { padding: 3rem; text-align: center; color: var(--muted-color); }

/* ---------- Footer ---------- */
.footer { background: #fff; border-top: 1px solid #e5e7eb; padding: 1.5rem 0; margin-top: auto; }
.footer-content { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.footer-links { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.footer-link { display: inline-flex; align-items: center; gap: 0.5rem; color: #6b7280; text-decoration: none; font-size: 0.875rem; }
.footer-link:hover { color: var(--primary-dark); }
.footer-text { color: #9ca3af; font-size: 0.875rem; text-align: center; }
.footer-text p { margin: 0; }

/* ---------- Toasts and dialogs ---------- */
#fv2Toasts { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem; }
.fv2-toast {
    background: #1a202c; color: white; padding: 0.75rem 1.25rem; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); font-size: 0.9rem; cursor: pointer;
    animation: fadeInUp 0.3s ease-out;
}
.fv2-toast-success { background: #059669; }
.fv2-toast-error { background: var(--danger-color); }

.fv2-dialog { border: none; border-radius: 16px; padding: 1.5rem; max-width: 420px; width: 90vw; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.fv2-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.fv2-dialog h5 { font-weight: 700; margin-bottom: 0.75rem; }
.fv2-dialog p { color: var(--muted-color); }
.fv2-dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
    .header-toggle-btn { display: block; }
    .btn-pill-action span { display: none; }
    .btn-pill-action { width: 45px; height: 45px; padding: 0; justify-content: center; border-radius: 50%; }
    .header-username { display: none; }
    .glass-header { position: sticky; top: 0; }
    body { padding-top: 0; }
    .sidebar { transform: translateX(-100%); width: 280px; top: 0; height: 100vh; }
    .sidebar.mobile-show { transform: translateX(0); }
    .wrapper.with-sidebar #content, body.sidebar-is-collapsed .wrapper.with-sidebar #content { margin-left: 0; }
    #content { padding: 1.5rem; }
    .sidebar-toggle-internal { display: none; }
}

/* The free-text box of an "Other" choice, aligned under the choice it belongs
   to. Lives here rather than in form.css because the builder preview draws the
   same field. */
.fv2-other-text { margin-top: 0.4rem; margin-left: 2.2rem; width: calc(100% - 2.2rem); }
