/* custom_layout.css - 午後の月 統合デザインシステム */

:root {
    --bg-base: #f0f2f5;
    --bg-surface: #ffffff;
    --text-main: #1c1e21;
    --text-muted: #65676b;
    --primary-color: #0d6efd;
    --secondary-color: #198754;
    --border-color: #e4e6eb;
    --nav-bg: #ffffff;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    --visited-color: #6f42c1;
}

[data-theme="dark"],
[theme="dark"] {
    --bg-base: #18191a;
    --bg-surface: #242526;
    --text-main: #e4e6eb;
    --text-muted: #b0b3b8;
    --primary-color: #4da3ff;
    --secondary-color: #2eb872;
    --border-color: #3e4042;
    --nav-bg: #242526;
    --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    --visited-color: #c586c0;
}

/* Base Body Styles */
body.theme-container {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, 'Noto Sans JP', sans-serif;
    margin: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

/* Link Base */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: opacity 0.2s;
}

a:visited {
    color: var(--visited-color);
}

a:hover {
    opacity: 0.8;
}

/* 訪問済みカラーの上書き（UI要素用） */
.app-header a:visited,
.app-sidebar a:visited,
.app-bottom-nav a:visited,
.nav-item:visited,
.bottom-nav-item:visited,
.btn-primary-new:visited,
.btn-secondary-new:visited,
.card-header-new a:visited,
.archive-item a:visited{
    color: inherit;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--nav-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 64px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.header-brand a {
    color: var(--text-main);
    font-size: 1.5rem;
    font-weight: 800;
    text-decoration: none;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-brand a span {
    color: var(--primary-color);
}

.btn-icon {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-main);
    transition: background-color 0.2s, transform 0.1s;
}

.btn-icon:hover {
    background-color: var(--border-color);
}

.btn-icon:active {
    transform: scale(0.95);
}

/* Layout */
.app-layout {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 64px);
}

/* Sidebar */
.app-sidebar {
    width: 260px;
    border-right: 1px solid var(--border-color);
    padding: 24px 0;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
    background-color: var(--nav-bg);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.nav-item {
    padding: 12px 24px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s, color 0.2s;
    border-radius: 0 24px 24px 0;
    margin-right: 16px;
    margin-bottom: 4px;
}

.nav-item:hover,
.nav-item.active {
    background-color: var(--bg-base);
    color: var(--primary-color);
}

.nav-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 16px 24px;
}

/* Main Content */
.app-main {
    flex: 1;
    padding: 32px;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 32px;
    max-width: 100%;
}

.content-area {
    min-width: 0;
    /* Prevents overflow in grid */
}

.side-content-area {
    position: sticky;
    top: 80px;
    align-self: start;
}

/* Responsive Hide/Show */
.hide-on-mobile {
    display: block;
}

.hide-on-pc {
    display: none;
}

/* Dashboard Cards */
.card-new {
    background-color: var(--bg-surface);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-new:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.card-header-new {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* List Items inside Cards */
.card-list-new {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card-list-item-new {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-list-item-new:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.item-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 4px 0;
}

.item-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.item-tag {
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.item-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-line;
}

/* Read More Button */
.btn-primary-new {
    display: inline-block;
    background-color: var(--primary-color);
    color: #fff !important;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
}

.btn-primary-new:hover {
    opacity: 0.9;
}

.btn-primary-new:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.card-action {
    margin-top: 16px;
    text-align: right;
}

/* Dashboard Specific Components */
.dashboard-hero {
    background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-base) 100%);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px 40px;
    margin-bottom: 32px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.hero-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0 0 16px 0;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 800px;
    margin: 0 0 24px 0;
}

.hero-notice {
    font-size: 0.9rem;
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.hero-notice a {
    text-decoration: underline;
    font-weight: bold;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
}

.card-new {
    display: flex;
    flex-direction: column;
}

.card-header-new .icon {
    font-size: 1.5rem;
}

.card-body {
    flex-grow: 1;
}

.meta-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.meta-link:hover {
    text-decoration: underline;
}

.tag-info {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

.meta-date {
    display: flex;
    align-items: center;
}

/* Modern Form Styles */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}

.form-control-new {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-surface);
    color: var(--text-main);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.form-control-new:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15); /* Adjust opacity based on primary color */
}

textarea.form-control-new {
    min-height: 150px;
    resize: vertical;
}

.help-text-new {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Global styling for common/form.html output */
.form-block.form-django {
    margin-bottom: 24px;
}
.form-block.form-django label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}
.form-block.form-django input[type="text"],
.form-block.form-django input[type="email"],
.form-block.form-django input[type="password"],
.form-block.form-django input[type="number"],
.form-block.form-django input[type="date"],
.form-block.form-django input[type="time"],
.form-block.form-django input[type="url"],
.form-block.form-django select,
.form-block.form-django textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-surface);
    color: var(--text-main);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.form-block.form-django textarea {
    min-height: 150px;
    resize: vertical;
}
.form-block.form-django input[type="checkbox"],
.form-block.form-django input[type="radio"] {
    margin-right: 8px;
    transform: scale(1.2);
}
.form-block.form-django input:focus,
.form-block.form-django select:focus,
.form-block.form-django textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}
.form-message {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-notice {
    background: var(--bg-surface);
    border-left: 4px solid var(--secondary-color);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 32px;
    box-shadow: var(--card-shadow);
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.form-notice h3, .form-notice h4, .form-notice h2 {
    margin-top: 0;
    margin-bottom: 12px;
    color: var(--text-main);
    font-size: 1.25rem;
}

.form-notice ul {
    margin: 0;
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.form-notice li {
    margin-bottom: 8px;
}


.btn-secondary-new {
    display: inline-block;
    background-color: var(--secondary-color);
    color: #fff !important;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
}

.btn-secondary-new:hover {
    opacity: 0.9;
}

@media (max-width: 1024px) {
    .app-main {
        grid-template-columns: 1fr;
        /* Stack side content */
    }
}

@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }

    .hide-on-pc {
        display: flex !important;
    }

    .app-header {
        padding: 0 16px;
    }

    .app-main {
        padding: 16px;
        padding-bottom: 80px;
        /* Space for bottom nav */
    }

    .app-bottom-nav {
        position: fixed;
        bottom: 0;
        width: 100%;
        background-color: var(--nav-bg);
        border-top: 1px solid var(--border-color);
        display: flex;
        justify-content: space-around;
        padding: 8px 0;
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom, 8px);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .bottom-nav-item {
        text-align: center;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.7rem;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        transition: color 0.2s;
    }

    .bottom-nav-item span {
        font-weight: 600;
    }

    .bottom-nav-item:hover,
    .bottom-nav-item.active {
        color: var(--primary-color);
    }

    .card-new {
        padding: 16px;
    }
}



/* Categories List */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}
.site-card-lp {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
}
.site-card-lp h3 {
    margin: 0 0 12px 0;
    font-size: 1.25rem;
    font-weight: 800;
}
.site-card-lp h3 a:hover {
    color: var(--primary-color);
}
.site-tag-list {
    margin: 0 0 12px 0;
    padding: 0;
    list-style: none;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.site-tag {
    font-size: 0.75rem;
    padding: 4px 10px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-weight: 600;
    color: var(--text-muted);
}
.site-tag.target { color: var(--secondary-color); border-color: var(--secondary-color); }
.site-info-row {
    margin-bottom: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-muted);
}
.site-info-row strong {
    color: var(--text-main);
}
.site-link-btn {
    margin-top: auto;
    padding-top: 16px;
    text-align: right;
}
.site-link-btn a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    transition: background 0.2s, border-color 0.2s;
}
.site-link-btn a:hover {
    background: var(--border-color);
    color: var(--primary-color);
}



/* -------------------------------------------------------------------------- */
/* Mobile Menu Drawer                                                         */
/* -------------------------------------------------------------------------- */

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100vh;
    background-color: var(--nav-bg);
    z-index: 1050;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.mobile-menu-drawer.active {
    right: 0;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

/* -------------------------------------------------------------------------- */
/* Pagination Styles                                                          */
/* -------------------------------------------------------------------------- */

.pagination-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 32px 0;
}

.pagination-new {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 8px;
}

.pagination-new .page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    box-sizing: border-box;
}

.pagination-new .page-item a.page-link:hover {
    background: var(--bg-base);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.pagination-new .page-item.active .page-link {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    cursor: default;
}

.page-jump {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-jump input {
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    width: 70px;
    box-sizing: border-box;
    font-size: 0.95rem;
}

.page-jump input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

/* Pre-wrap text overrides */
.read-more-content,
.text-pre-wrap {
    white-space: pre-wrap;
}
