/* styles/_layout.css - Page Layout & Structure */

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 30px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

header .branding {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--header-height);
    gap: 0.85rem;
}

header .branding.align-left {
    justify-content: flex-start;
}

header .branding.align-center {
    justify-content: center;
}

header .branding.align-right {
    justify-content: flex-end;
}

header .branding img.site-logo {
    max-height: 56px;
    width: auto;
    display: block;
}

header .branding h1 {
    margin: 0;
    font-size: 1.9rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

header .branding img.site-logo + h1 {
    margin-left: 0.8rem;
}

header + nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: visible;
    gap: 0.6rem;
    padding: 0 30px;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    z-index: 99;
}

.admin-sidebar-nav {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    width: auto;
    display: block;
}

nav a {
    color: var(--text);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 12px;
    transition: background 0.2s ease, color 0.2s ease;
    background: rgba(255, 255, 255, 0.04);
}

nav a:hover {
    background: rgba(96, 165, 250, 0.16);
}

nav a.primary,
nav a.active {
    background: var(--accent-strong);
    color: #ffffff;
}

nav a.success {
    background: var(--success);
    color: #0f172a;
}

nav a.danger {
    background: var(--danger);
    color: #ffffff;
}

main {
    flex: 1;
    max-width: 1400px;
    width: min(100%, 1400px);
    margin: calc(var(--top-bar-height) + 28px) auto 0;
    padding: 0 20px 40px;
}

footer {
    margin-top: auto;
}

.page-section {
    max-width: 1000px;
    margin: 24px auto 0;
}

footer {
    padding: 18px 30px;
    text-align: center;
    color: var(--muted);
    font-size: 0.92rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer-links {
    margin-top: 10px;
}

.footer-links ul {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.footer-links li {
    margin: 0;
}

.footer-links a {
    color: var(--text);
    text-decoration: underline;
    opacity: 0.8;
}

.footer-links a:hover {
    opacity: 1;
}

.article-header,
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.section-panel,
.form-panel,
.card-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
}

/* Admin layout: fixed left sidebar and main content area */
.admin-layout {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    padding: 24px;
}

.admin-sidebar {
    width: 220px;
    position: fixed;
    left: 24px;
    top: calc(var(--top-bar-height) + 24px);
    bottom: 24px;
    overflow: auto;
    z-index: 80;
    background: var(--surface-strong);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.16);
}

.admin-sidebar-nav {
    padding: 12px;
    background: var(--surface-strong);
    border-radius: 12px;
    border: 1px solid var(--border-strong);
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Sidebar Nav Collapsible Groups */
.nav-group-wrapper {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
    margin-top: 12px;
}

.nav-group-header:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.nav-group-arrow {
    display: inline-block;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
    color: var(--muted);
}

.nav-group-wrapper.expanded .nav-group-arrow {
    transform: rotate(90deg);
}

.nav-group-sub-list {
    list-style: none;
    padding: 0;
    margin: 4px 0 8px 8px;
    display: none;
    flex-direction: column;
    gap: 6px;
    border-left: 2px solid var(--border);
    padding-left: 10px;
}

.nav-group-wrapper.expanded .nav-group-sub-list {
    display: flex;
}

.nav-link {
    display: block;
    padding: 10px 12px;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.nav-link:hover {
    background: rgba(255,255,255,0.02);
}

.nav-link.active {
    background: var(--accent-strong);
    color: #fff;
    font-weight: 700;
}

.nav-sep {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.admin-main {
    margin-left: 280px; /* leave space for fixed sidebar */
    flex: 1 1 auto;
    padding-top: 16px;
}

.admin-main .page-section {
    max-width: none;
    margin: 24px 0;
}

@media (max-width: 900px) {
    .admin-sidebar { position: static; width: 100%; max-height: none; top: auto; margin-bottom: 12px; }
    .admin-main { margin-left: 0; }
    .admin-layout { padding: calc(var(--top-bar-height) + 12px) 12px 12px 12px; }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.section-header h2,
.section-header h3,
.section-header h4 {
    margin: 0;
}

@media (max-width: 760px) {
    nav {
        justify-content: center;
    }

    main {
        padding: 0 16px 30px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }
}
