/* Shared styles for index (welcome) and readme pages */

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

html, body { margin: 0; padding: 0; }
html, body.page-index { height: 100%; }

body {
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background-color: #EDEDEC;
    color: #232323;
    line-height: 1.6;
    transition: background-color 0.2s ease, color 0.2s ease;
}

body.page-index {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* Layout: index */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 2rem;
    padding: 1.5rem;
}

h1 { font-size: 2rem; font-weight: 700; margin: 0; }

/* Layout: readme */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 2rem;
    border-bottom: 1px solid #d4d4d0;
    background-color: #EDEDEC;
}
.topbar a { color: inherit; text-decoration: none; font-weight: 500; }
.topbar a:hover { text-decoration: underline; }
.topbar .logo { height: 32px; width: auto; display: block; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }

.content {
    max-width: 860px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}
.content h1, .content h2, .content h3, .content h4 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    line-height: 1.25;
}
.content h1 { font-size: 2rem; border-bottom: 1px solid #d4d4d0; padding-bottom: 0.5rem; }
.content h2 { font-size: 1.5rem; border-bottom: 1px solid #d4d4d0; padding-bottom: 0.3rem; }
.content h3 { font-size: 1.25rem; }
.content p, .content ul, .content ol { margin: 0.75rem 0; }
.content ul, .content ol { padding-left: 1.5rem; }
.content a { color: #2563eb; text-decoration: none; }
.content a:hover { text-decoration: underline; }
.content code {
    background-color: #dcdcd8;
    padding: 0.15rem 0.35rem;
    border-radius: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}
.content pre {
    background-color: #dcdcd8;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
}
.content pre code { background: transparent; padding: 0; }
.content blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    border-left: 4px solid #c4c4c0;
    color: #555;
    background-color: #e3e3e0;
}
.content table { border-collapse: collapse; margin: 1rem 0; }
.content th, .content td { border: 1px solid #d4d4d0; padding: 0.5rem 0.75rem; }
.content img { max-width: 100%; height: auto; }

/* Logo */
.logo { width: 100%; max-width: 320px; height: auto; display: block; }
.logo.logo-dark { display: none; }

/* Buttons / links */
.docs-link {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: #EDEDEC;
    background-color: #232323;
    border: 1px solid #232323;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.docs-link:hover { background-color: #EDEDEC; color: #232323; }

/* Theme toggle */
.theme-toggle {
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    color: inherit;
    border: 1px solid #232323;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { background-color: #232323; color: #EDEDEC; }
.theme-toggle .icon-dark { display: none; }

.theme-toggle-fixed {
    position: fixed;
    top: 1rem;
    right: 1rem;
}

/* Dark theme */
:root[data-theme="dark"] body { background-color: #232323; color: #EDEDEC; }
:root[data-theme="dark"] .topbar { background-color: #232323; border-bottom-color: #343434; }
:root[data-theme="dark"] .docs-link { background-color: #EDEDEC; color: #232323; border-color: #EDEDEC; }
:root[data-theme="dark"] .docs-link:hover { background-color: transparent; color: #EDEDEC; }
:root[data-theme="dark"] .theme-toggle { border-color: #EDEDEC; }
:root[data-theme="dark"] .theme-toggle:hover { background-color: #EDEDEC; color: #232323; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: inline; }
:root[data-theme="dark"] .logo.logo-light { display: none; }
:root[data-theme="dark"] .logo.logo-dark { display: block; }
:root[data-theme="dark"] .content h1,
:root[data-theme="dark"] .content h2 { border-bottom-color: #343434; }
:root[data-theme="dark"] .content code,
:root[data-theme="dark"] .content pre { background-color: #161615; }
:root[data-theme="dark"] .content blockquote { background-color: #141413; border-left-color: #3a3a37; color: #b8b8b3; }
:root[data-theme="dark"] .content th,
:root[data-theme="dark"] .content td { border-color: #343434; }
:root[data-theme="dark"] .content a { color: #60a5fa; }

/* Login page */
body.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
    width: 100%;
    max-width: 360px;
    padding: 2rem;
    text-align: center;
}
.login-card .logo { max-width: 220px; align-self: center; }
.login-card h1 { font-size: 1.5rem; }
.login-submit { width: 100%; text-align: center; border-radius: 0.5rem; cursor: pointer; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; max-width: 480px; text-align: left; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-weight: 500; font-size: 0.9rem; }
.form-group input,
.form-group select {
    padding: 0.55rem 0.75rem;
    font-size: 1rem;
    font-family: inherit;
    color: inherit;
    background-color: #fff;
    border: 1px solid #c4c4c0;
    border-radius: 0.375rem;
}
.form-actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.5rem; }

.btn {
    display: inline-block;
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: inherit;
    background-color: transparent;
    border: 1px solid #232323;
    border-radius: 0.5rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background-color: #232323; color: #EDEDEC; }
.btn-ghost { border-color: transparent; padding: 0.5rem 0.9rem; font-size: 0.9rem; }
.btn-ghost:hover { background-color: rgba(35, 35, 35, 0.1); color: inherit; }
.btn-link-danger {
    background: none;
    border: none;
    padding: 0;
    color: #b91c1c;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
}

/* Alerts */
.alert { padding: 0.85rem 1.1rem; border-radius: 0.5rem; margin-bottom: 1.25rem; font-size: 0.9rem; }
.alert ul { margin: 0; padding-left: 1.25rem; }
.alert-success { background-color: #dcfce7; color: #166534; }
.alert-error { background-color: #fee2e2; color: #991b1b; }

/* Admin layout */
.page-admin .topbar { padding: 0.85rem 2rem; }
.topbar-user { font-size: 0.9rem; font-weight: 500; }
.topbar-nav { display: flex; align-items: center; gap: 1.25rem; margin-left: 1.5rem; margin-right: auto; }
.topbar-nav a { color: inherit; text-decoration: none; font-size: 0.9rem; font-weight: 500; opacity: 0.7; }
.topbar-nav a:hover, .topbar-nav a.active { opacity: 1; text-decoration: underline; }
.admin-content { max-width: 1080px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.admin-header h1 { margin: 0; }

/* Error logs */
.badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 9999px; font-size: 0.8rem; font-weight: 600; }
.badge-4xx { background-color: #fef3c7; color: #92400e; }
.badge-5xx { background-color: #fee2e2; color: #991b1b; }

.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bulk-toolbar { display: flex; justify-content: flex-end; margin-bottom: 0.75rem; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem 1.5rem; margin-bottom: 1.5rem; }
.detail-grid > div { display: flex; flex-direction: column; gap: 0.2rem; }
.detail-label { font-size: 0.8rem; font-weight: 600; opacity: 0.65; text-transform: uppercase; letter-spacing: 0.03em; }

.detail-block {
    background-color: #dcdcd8;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.filter-form { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.filter-form input {
    flex: 1;
    max-width: 320px;
    padding: 0.55rem 0.75rem;
    border: 1px solid #c4c4c0;
    border-radius: 0.375rem;
    font-family: inherit;
    font-size: 0.95rem;
}

.table-wrapper { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
    text-align: left;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid #d4d4d0;
    font-size: 0.9rem;
}
.admin-table th { font-weight: 600; }
.admin-actions { display: flex; gap: 0.85rem; align-items: center; white-space: nowrap; }
.admin-actions a { color: inherit; }

/* Pagination (bootstrap-4 view) */
.pagination-wrapper { margin-top: 1.5rem; }
.pagination { display: flex; list-style: none; gap: 0.25rem; padding: 0; margin: 0; flex-wrap: wrap; }
.pagination .page-item .page-link {
    display: inline-block;
    padding: 0.4rem 0.75rem;
    border: 1px solid #c4c4c0;
    border-radius: 0.375rem;
    color: inherit;
    text-decoration: none;
    font-size: 0.85rem;
}
.pagination .page-item.active .page-link { background-color: #232323; color: #EDEDEC; border-color: #232323; }
.pagination .page-item.disabled .page-link { opacity: 0.5; }

/* Dark theme additions */
:root[data-theme="dark"] .form-group input,
:root[data-theme="dark"] .form-group select,
:root[data-theme="dark"] .filter-form input { background-color: #2c2c2b; border-color: #3a3a37; color: #EDEDEC; }
:root[data-theme="dark"] .btn { border-color: #EDEDEC; }
:root[data-theme="dark"] .btn:hover { background-color: #EDEDEC; color: #232323; }
:root[data-theme="dark"] .btn-ghost:hover { background-color: rgba(237, 237, 236, 0.15); }
:root[data-theme="dark"] .alert-success { background-color: #14532d; color: #bbf7d0; }
:root[data-theme="dark"] .alert-error { background-color: #450a0a; color: #fecaca; }
:root[data-theme="dark"] .admin-table th, :root[data-theme="dark"] .admin-table td { border-bottom-color: #343434; }
:root[data-theme="dark"] .pagination .page-item .page-link { border-color: #3a3a37; }
:root[data-theme="dark"] .pagination .page-item.active .page-link { background-color: #EDEDEC; color: #232323; border-color: #EDEDEC; }
:root[data-theme="dark"] .badge-4xx { background-color: #451a03; color: #fde68a; }
:root[data-theme="dark"] .badge-5xx { background-color: #450a0a; color: #fecaca; }
:root[data-theme="dark"] .detail-block { background-color: #161615; }
