/* ----------------------------------------------------
   LOVEBU Admin - Common / Base Styles
   ---------------------------------------------------- */

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

:root {
    /* Brand Colors */
    --gold: #B68D38;
    --gold-sub: #CBAD6E;
    --gold-dark: #A06C00;
    --bg-dark: #111214; 
    --bg-light: #F0F2F5; /* Darkened dashboard body bg */
    --bg-card: #1A1A1A; 
    --bg-input: #242424;
    /* Secondary (light) surfaces used for table headers/panels */
    --bg-secondary: #F1F5F9;
    --border-light: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.12);
    
    /* Text Colors */
    --text-primary: #FFFFFF;
    --text-body: #333333;
    --text-muted: #A0A0A0;
    --text-dark: #222222;
    
    /* Status Colors */
    --danger: #EB3861;
    --success: #23C795;
    --warning: #FB923C;
    --info: #3B82F6;
    
    /* UI Values */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-card: 0 10px 40px rgba(0, 0, 0, 0.15);
    --transition: all 0.2s ease;
    
    /* Layout Sizes */
    --sidebar-width: 280px;
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

/* Prevent layout shift when content toggles causes vertical scrollbar */
html {
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-dark); /* Default back to dark */
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "palt";
}

/* Typography Base */
h1, h2, h3, h4, h5 {
    font-weight: 700;
}

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

ul {
    list-style: none;
}

button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
    transition: var(--transition);
}

input {
    font-family: inherit;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
}

.badge i {
    width: 12px;
    height: 12px;
}

.badge-gray { background-color: #E2E8F0; color: #475569; }
.badge-success { background-color: #DCFCE7; color: #166534; }
.badge-warning { background-color: #FEF3C7; color: #92400E; }
.badge-danger { background-color: #FEE2E2; color: #991B1B; }
.badge-info { background-color: #E0F2FE; color: #0369A1; }
.badge-primary { background-color: #DBEAFE; color: #1E40AF; }
.badge-secondary { background-color: #F1F5F9; color: #475569; }
.badge-purple { background-color: #F4F4FF; color: #7C3AED; } /* A nice soft purple/indigo */

.badge-success-outline { 
    background-color: rgba(35, 199, 149, 0.1); 
    color: var(--success);
    border: 1px solid rgba(35, 199, 149, 0.2);
}

.badge-danger-outline {
    background-color: rgba(235, 56, 97, 0.1);
    color: var(--danger);
    border: 1px solid rgba(235, 56, 97, 0.2);
}

/* --- Global Header Utilities --- */
.chapter-select {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-body);
}

.chapter-select i {
    width: 20px;
    height: 20px;
    color: #666;
}

.chapter-dropdown {
    min-width: 120px;
}

/* --- Auth Page (Login) --- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-dark);
}

.auth-card {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 440px;
    padding: 3.5rem 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-card);
}

.auth-logo {
    text-align: center;
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: 2.5rem;
    color: var(--text-primary);
}

.auth-form-group {
    margin-bottom: 1.5rem;
}

.auth-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.auth-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.auth-input::placeholder {
    color: var(--text-dark);
}

.auth-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}

.auth-input-icon {
    position: absolute;
    right: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
}

.auth-footer-links {
    text-align: right;
    margin-top: 0.75rem;
}

.auth-link {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.auth-link:hover {
    color: var(--text-primary);
}

.auth-submit-btn {
    width: 100%;
    background-color: var(--gold);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 1rem;
    font-size: 1rem;
    font-weight: 700;
    margin-top: 2rem;
}

.auth-submit-btn:hover {
    background-color: var(--gold-sub);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(182, 141, 56, 0.3);
}

.auth-submit-btn:active {
    transform: translateY(0);
}

/* --- Dashboard Layout --- */
.admin-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-light);
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    border-right: 1px solid var(--border-light);
}

.sidebar-brand {
    padding: 2rem;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.04em;
    user-select: none;
}

.sidebar-nav {
    flex: 1;
    padding: 0 1rem;
    overflow-y: auto;
}

.nav-section-title {
    padding: 0rem 1rem 0.75rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    opacity: 0.6;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05); /* ニュートラル白の透過 */
    color: var(--text-primary);
}

.nav-link.active {
    background-color: rgba(182, 141, 56, 0.1);
    color: var(--gold);
}

.nav-badge {
    margin-left: auto;
    background-color: var(--danger);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 20px;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-light);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background-color: var(--bg-input);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    border-radius: var(--radius-md);
    background-color: rgba(235, 56, 97, 0.1);
    color: var(--danger);
    width: 100%;
    font-weight: 600;
    font-size: 0.85rem;
}

.logout-link:hover {
    background-color: var(--danger);
    color: white;
}

/* Wraps top-header + main so body (--bg-dark) does not show as a strip between them */
.main-wrapper {
    min-width: 0;
    min-height: 100vh;
    background-color: var(--bg-light);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    background-color: var(--bg-light);
    color: var(--text-body);
}

.top-header {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    background-color: white;
    border-bottom: 1px solid #EEEEEE;
    position: sticky;
    top: 0;
    z-index: 50;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #222222;
}

.header-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.breadcrumb {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-icon-btn {
    color: #64748B;
    position: relative;
    padding: 4px;
}

.header-icon-btn:hover {
    color: var(--gold);
}

.notification-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid white;
}

/* --- Notification Dropdown --- */
.notification-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 380px;
    background-color: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid #EEEEEE;
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.notification-dropdown.active {
    display: block;
    animation: slideInUp 0.2s ease;
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.notification-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #F1F5F9;
}

.notification-title {
    font-size: 1rem;
    font-weight: 700;
    color: #222222;
}

.notification-header-actions {
    display: flex;
    gap: 1rem;
    color: #64748B;
}

.notification-header-actions i {
    width: 18px;
    height: 18px;
}

.notification-header-actions i:hover {
    color: var(--gold);
}

.notification-body {
    max-height: 400px;
    overflow-y: auto;
    text-align: left; /* Ensure left alignment */
}

.notification-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 1rem; /* 1.25rem 1.5rem から 1rem 1rem へスリム化 */
    border-bottom: 1px solid #F8F8F8;
    cursor: pointer;
}

.notification-item:hover {
    background-color: #F8FAFC;
}

.notification-item.unread {
    background-color: rgba(182, 141, 56, 0.03);
    border-left: 3px solid var(--gold);
}

.notification-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #F59E0B;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.notification-content h4 {
    font-size: 0.9rem;
    font-weight: 500;
    color: #444444;
    margin-bottom: 2px;
}

.notification-item.unread .notification-content h4 {
    font-weight: 700;
    color: #222222;
}

.notification-content p {
    font-size: 0.8rem;
    color: #666666;
    margin-bottom: 4px;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.notification-settings {
    padding: 1rem 1.5rem;
    border-top: 1px solid #F1F5F9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #FCFCFC;
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #444444;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { display: none; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #E2E8F0;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--gold);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.notification-footer {
    padding: 1rem;
    text-align: center;
    border-top: 1px solid #F1F5F9;
}

.notification-footer a {
    font-size: 0.85rem;
    font-weight: 700;
    color: #3B82F6;
}

.notification-footer a:hover {
    text-decoration: underline;
}

/* --- Weekly Calendar Picker --- */
.weekly-calendar-filter {
    margin-top: 0rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--border-color);
}
.weekly-calendar-filter .title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.week-picker {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.week-picker::-webkit-scrollbar {
    display: none;
}
.day-btn {
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    height: 60px;
    border-radius: var(--radius-md);
    background: #F8F9FA;
    border: 1px solid #EEEEEE;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-main);
}
.day-btn:hover {
    background: #F1F5F9;
    border-color: #E2E8F0;
}
.day-btn.active {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}
.day-btn.active.saturday, .day-btn.active.sunday {
    color: white !important;
}
.day-btn .day-name {
    font-size: 0.7rem;
    margin-bottom: 2px;
    opacity: 0.8;
}
.day-btn .day-num {
    font-size: 1.1rem;
    font-weight: 700;
}
.day-btn.today {
    border: 2px solid var(--danger);
    color: var(--danger);
    background: white;
}
.day-btn.today.active {
    color: white;
    background: var(--danger);
}
.day-btn.saturday { color: #3b82f6; }
.day-btn.sunday { color: #ef4444; }

/* --- Action Color Utilities --- */
.red:hover, .pink:hover, .dark:hover, .info:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.red {
    background-color: var(--danger);
    color: white;
}

.pink {
    background-color: #F472B6;
    color: white;
}

.dark {
    background-color: var(--text-dark);
    color: white;
}

.info {
    background-color: #3B82F6;
    color: white;
}

.danger-outline {
    border: 1px solid var(--danger);
    color: var(--danger);
    background: transparent;
}

.danger-outline:hover {
    background-color: var(--danger);
    color: white;
    transform: translateY(-2px);
}

/* --- Modal Styles --- */
/* Closed: display:none so the overlay is not painted or laid out (avoids flash on load/refresh). Open: .active sets flex + opacity. */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content-card {
    background-color: white;
    width: 100%;
    max-width: 560px;
    border-radius: 1.5rem;
    overflow: hidden;
    transform: scale(0.9);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-content-card {
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #F1F5F9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #222222;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #F8F9FA;
    color: #444;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 0; /* allow flex children to shrink so footer stays visible under max-height */
}

.form-group-stack label {
    display: block;
    font-size: 0.85rem;
    font-weight: 800;
    color: #222222;
    margin-bottom: 0.75rem;
}

.required {
    color: var(--danger);
    margin-left: 2px;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.modal-footer {
    padding: 1.5rem 2rem;
    background-color: #FBFBFB;
    border-top: 1px solid #F1F5F9;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-modal-cancel {
    padding: 0.75rem 1.5rem;
    border: 1px solid #EEEEEE;
    border-radius: var(--radius-md);
    background-color: white;
    font-weight: 700;
    color: #64748B;
    cursor: pointer;
}

.btn-modal-submit {
    border: none;
    cursor: pointer;
    background-color: var(--gold);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: var(--transition);
}

.btn-modal-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: none;
    transform: none;
}

.btn-modal-submit:disabled:hover {
    filter: none;
    transform: none;
}

.btn-modal-submit.red {
    background-color: var(--danger);
}

.btn-modal-submit:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

/* Make modal form controls match LOVEBU admin theme */
.modal-overlay .form-input,
.modal-overlay .form-select {
    width: 100% !important;
    height: 44px !important;
    padding: 0 0.6rem !important;
    border: 1px solid #EEEEEE !important;
    border-radius: var(--radius-md) !important;
    background-color: #FBFBFB !important;
    font-size: 0.9rem !important;
    color: var(--text-body) !important;
    transition: var(--transition) !important;
}

.modal-overlay .form-input:focus,
.modal-overlay .form-select:focus {
    outline: none !important;
    border-color: var(--gold) !important;
    box-shadow: 0 0 0 3px rgba(182, 141, 56, 0.18) !important;
}

.modal-overlay .form-label {
    display: block !important;
    font-weight: 600 !important;
    color: #222222 !important;
}

/* --- Toast Notification --- */
.toast-notification {
    position: fixed;
    top: 24px;
    right: 24px;
    background-color: #333;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 2000;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    font-weight: 600;
    font-size: 0.9rem;
    border-left: 4px solid var(--gold);
}

.toast-notification.active {
    transform: translateX(0);
}

.toast-notification i {
    width: 20px;
    height: 20px;
    color: var(--gold);
}

.toast-notification.success {
    border-left-color: var(--success);
}
.toast-notification.success i {
    color: var(--success);
}

/* --- Tablet / Small Desktop Adjustments --- */
@media (max-width: 1200px) {
    /* Keep header aligned with .main-content (sidebar width); 80px caused a dark body strip next to the sidebar */
    .top-header {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}

/* --- Responsive Design (Mobile) --- */
@media (max-width: 768px) {
    /* Layout Adjustments */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.2);
    }
    
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 90;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        min-width: 100%;
    }
    
    .top-header {
        padding: 0 0.75rem;
        height: 64px;
        margin-left: 0;
        width: 100%;
    }

    /* Mobile Header Icons */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        margin-right: 8px;
        color: var(--text-dark);
        background: #F8F9FA;
        border-radius: 8px;
        flex-shrink: 0;
    }

    .header-left {
        gap: 0rem;
        overflow: hidden;
    }

    .header-title {
        font-size: 1rem;
        white-space: nowrap;
    }

    .breadcrumb {
        display: none;
    }

    .header-actions {
        gap: 0.5rem;
    }

    /* Chapter select adjustment */
    .chapter-dropdown {
        min-width: 80px !important;
    }
    .chapter-select {
        gap: 4px;
    }

    /* Notification Dropdown Centering on Mobile */
    .notification-dropdown {
        position: fixed !important;
        top: 70px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) translateY(10px) !important;
        width: calc(100vw - 32px) !important;
        max-width: 400px !important;
        margin: 0 !important;
        opacity: 0;
        visibility: hidden;
    }
    .notification-dropdown.active {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateX(-50%) translateY(0) !important;
    }
}

/* Hide toggle by default on desktop */
.mobile-menu-toggle {
    display: none;
}

/* Scrollable Table for Mobile */
.card.overflow-hidden {
    overflow-x: auto !important;
}

.data-table {
    min-width: 600px; /* Force minimum width to trigger scroll on mobile */
}
