/* ============================================================
   1. デザインシステム変数 (Design Tokens)
   ============================================================ */
:root {
    --legal-primary-dark: #001a17;
    --legal-primary: #00453e;
    --legal-accent: #00c2a8;
    --legal-interactive: #0d6efd;
    --legal-bg-light: #f8fafc;
    --legal-text-main: #1e293b;
    --legal-text-muted: #64748b;
    --font-family-soft: 'Inter', 'Noto Sans JP', 'Helvetica Neue', Arial, sans-serif;
    --sidebar-width: 280px;
    /* ハイライト用カラー定義 */
    --highlight-active: #f59e0b; /* Amber */
    --highlight-done: #10b981; /* Emerald */
}

/* ============================================================
   2. 全体・基本設定 (Global)
   ============================================================ */
html, body {
    font-family: var(--font-family-soft);
    color: var(--legal-text-main);
    background-color: var(--legal-bg-light);
    margin: 0;
    padding: 0;
}

*, *::before, *::after {
    box-sizing: border-box;
}

a, .btn-link {
    color: var(--legal-interactive);
}

.majestic-title {
    font-weight: 800;
    font-size: 1.85rem;
    color: var(--legal-primary);
    letter-spacing: 0.05em;
    margin-bottom: 0.8rem !important;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

/* ============================================================
   3. サイドバー (Sidebar)
   ============================================================ */
.sidebar {
    background-image: linear-gradient(180deg, var(--legal-primary-dark) 0%, var(--legal-primary) 100%) !important;
    letter-spacing: 0.05em;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    user-select: none;
    z-index: 1030;
}

    .sidebar .top-row {
        background-color: rgba(0, 0, 0, 0.2) !important;
        height: 3.5rem;
        display: flex;
        align-items: center;
        padding: 0 1.5rem;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        justify-content: space-between;
    }

    .sidebar .navbar-brand {
        font-weight: 800;
        color: #ffffff !important;
        letter-spacing: 0.1em;
        font-size: 1.1rem;
        text-decoration: none;
    }

    .sidebar .navbar-toggler {
        background-color: transparent;
        border: none;
        padding: 0.25rem 0.5rem;
        font-size: 1rem;
        cursor: pointer;
        outline: none;
        box-shadow: none !important;
    }

        .sidebar .navbar-toggler:focus, .sidebar .navbar-toggler:active {
            outline: none;
            box-shadow: none !important;
            transform: scale(0.95);
        }

.nav-item {
    padding: 0.2rem 0.8rem;
}

.sidebar .nav-link {
    display: flex !important;
    align-items: center !important;
    padding: 0.7rem 1.0rem !important;
    color: rgba(255, 255, 255, 0.75) !important;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
    text-decoration: none;
}

    .sidebar .nav-link .bi {
        font-size: 1.2rem;
        width: 1.8rem;
        margin-right: 0.5rem !important;
        display: inline-flex;
        justify-content: center;
        opacity: 0.8;
    }

    .sidebar .nav-link:hover {
        color: #ffffff !important;
        background-color: rgba(255, 255, 255, 0.1) !important;
        transform: translateX(3px);
    }

        .sidebar .nav-link:hover .bi {
            opacity: 1;
        }

    .sidebar .nav-link.active {
        color: #ffffff !important;
        background-color: rgba(0, 194, 168, 0.25) !important;
        font-weight: 700;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        border-left: 3px solid var(--legal-accent);
    }

/* 訴訟管理メニュー専用のスタイル */
.litigation-nav-link {
    color: #d8b4fe !important;
    border-left: 3px solid transparent;
}

    .litigation-nav-link.active {
        border-left: 3px solid #d8b4fe !important;
        background-color: rgba(111, 66, 193, 0.15) !important;
        color: #ffffff !important;
    }

.nav-scrollable {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

    .nav-scrollable::-webkit-scrollbar {
        width: 6px;
    }

    .nav-scrollable::-webkit-scrollbar-track {
        background: transparent;
    }

    .nav-scrollable::-webkit-scrollbar-thumb {
        background-color: rgba(255, 255, 255, 0.2);
        border-radius: 20px;
    }

#nav-toggle-checkbox {
    display: none !important;
}

/* Sidebar History Item */
.history-item {
    background-color: rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

    .history-item:hover {
        background-color: rgba(255, 255, 255, 0.15);
        border-left: 2px solid #ffc107; /* warning color */
        transform: translateX(3px);
    }

@media (min-width: 768px) {
    .sidebar {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        height: 100vh;
        position: sticky;
        top: 0;
    }

        .sidebar .navbar-toggler {
            display: none;
        }

    .nav-content {
        display: block !important;
    }

    .nav-scrollable {
        height: calc(100vh - 3.5rem);
    }
}

@media (max-width: 767.98px) {
    .sidebar {
        width: 100vw;
        height: auto;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1030;
    }

    .nav-scrollable {
        max-height: calc(100vh - 3.5rem);
        background-color: var(--legal-primary);
        border-bottom: 1px solid rgba(0,0,0,0.1);
        box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    }

    .nav-content {
        display: none;
    }

    #nav-toggle-checkbox:checked ~ .nav-content {
        display: block !important;
        animation: slideDown 0.3s ease-out;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .main {
        padding-top: 3.5rem !important;
    }
}

/* ============================================================
   4. フォーム & ボタン (Forms & Buttons)
   ============================================================ */
.form-control, .form-select, .input-group-text {
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background-color: #ffffff;
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
}

.input-group-text {
    background-color: #f1f5f9;
    color: #64748b;
    font-weight: 700;
}

.form-control:focus, .form-select:focus {
    border-color: var(--legal-interactive) !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15) !important;
    outline: none;
}

.btn-majestic {
    border-radius: 50px;
    padding: 0.7rem 2.5rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    transition: all 0.2s;
    border: none;
}

.btn-save {
    background-color: var(--legal-interactive);
    color: white !important;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

    .btn-save:hover {
        transform: translateY(-2px);
        opacity: 0.95;
        box-shadow: 0 6px 15px rgba(13, 110, 253, 0.4);
    }

.btn-cancel {
    background-color: #f1f5f9;
    color: #64748b !important;
    border: 1px solid #e2e8f0;
}

    .btn-cancel:hover {
        background-color: #e2e8f0;
    }

.label-small {
    color: var(--legal-text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    display: block;
}

/* ============================================================
   5. モーダル & ログイン (Modals & Login)
   ============================================================ */
.majestic-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.majestic-modal-dialog {
    width: 90%;
    max-width: 850px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    overflow: hidden;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.login-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    background-color: var(--legal-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.login-card {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.input-refined-lg {
    height: 3.5rem;
    font-size: 1.1rem;
    border-radius: 12px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    font-weight: 700;
}

.btn-login {
    background-color: var(--legal-accent) !important;
    color: #ffffff !important;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(0, 194, 168, 0.4);
    border: none;
    width: 100%;
    border-radius: 50px;
    padding: 0.8rem;
    font-weight: bold;
}

    .btn-login:hover {
        background-color: #009688 !important;
        transform: translateY(-2px);
    }

/* ============================================================
   6. 共通グリッド & カレンダー (Calendar & Schedule Grid)
   ============================================================ */
.day-view-scroll {
    scroll-behavior: smooth;
}

/* --- A. Day View Grid --- */
.calendar-grid {
    display: grid;
    grid-template-rows: 60px auto;
    position: relative;
    min-width: 800px;
}

.time-grid-container {
    position: relative;
    padding-left: 60px;
    min-height: 900px;
}

/* Common Grid Elements */
.time-row, .time-slot {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
    box-sizing: border-box;
}

.time-label {
    position: absolute;
    left: -60px;
    width: 60px;
    text-align: center;
    top: -10px;
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 600;
    background-color: transparent;
}

.time-axis .time-slot {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 600;
    align-items: flex-start;
    padding-top: 8px;
}

.time-axis-header, .room-header, .task-header {
    background: #fff;
    z-index: 200;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.click-slot {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

    .click-slot:hover {
        background-color: rgba(13, 110, 253, 0.05);
    }

.room-column, .task-column, .time-axis {
    min-height: 900px;
    position: relative;
    background-image: linear-gradient(#f1f5f9 1px, transparent 1px);
    background-size: 100% 60px;
    background-position: 0 0;
    border-right: 1px solid #f1f5f9;
}

.time-axis {
    grid-column: 1;
    background-color: #fcfcfc;
    border-right: 1px solid #e2e8f0;
}

/* Entry Cards (Day View) */
.entry-card, .schedule-entry-card {
    position: absolute;
    width: 94%;
    left: 3%;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    z-index: 20;
    overflow: visible !important;
    border-left-width: 4px !important;
    border-left-style: solid !important;
    padding: 2px 6px;
    background: #fff;
    transition: all 0.15s;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-top: 1px solid rgba(0,0,0,0.05);
    border-right: 1px solid rgba(0,0,0,0.05);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

    .entry-card:hover, .schedule-entry-card:hover {
        z-index: 100;
        transform: scale(1.02);
        box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    }

    /* Day View ハイライト */
    .schedule-entry-card.target-highlight-active {
        border: 2px solid var(--highlight-active) !important;
        border-left: 6px solid var(--highlight-active) !important;
        box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4) !important;
        z-index: 50;
        transform: scale(1.01);
    }

    .schedule-entry-card.target-highlight-done {
        border: 2px solid var(--highlight-done) !important;
        border-left: 6px solid var(--highlight-done) !important;
        box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3) !important;
        z-index: 49;
        opacity: 0.95;
    }

.entry-content, .entry-inner, .entry-subject, .entry-time {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 100%;
}

.entry-subject {
    font-weight: 700;
}

.entry-time {
    font-size: 0.8rem;
    color: #64748b;
}

/* Now Indicator */
.now-indicator {
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 150;
    height: 1px;
}

.now-dot {
    position: absolute;
    left: -5px;
    top: -5px;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
}

.now-indicator-schedule .now-dot {
    left: 65px;
}

.now-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: #ef4444;
}

.now-indicator-schedule .now-line {
    left: 70px;
}

/* --- C. Week/Month View Grid --- */
.week-grid, .month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    height: auto;
    background-color: #cbd5e1;
    gap: 1px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
}

.week-col, .month-cell, .grid-cell {
    background-color: #fff;
    min-height: 140px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: background-color 0.1s;
    border: none !important;
}

    .week-col:hover, .month-cell:hover, .grid-cell:hover {
        background-color: #f8fafc;
    }

.bg-today {
    background-color: #f0f9ff !important;
}

/* Mini Entries */
.mini-entry {
    font-size: 0.75rem;
    padding: 2px 6px;
    margin-bottom: 2px;
    border-radius: 4px;
    overflow: visible !important;
    font-weight: 600;
    color: #334155;
    border-left-width: 3px !important;
    border-left-style: solid !important;
    cursor: pointer;
    background-color: #f1f5f9;
    position: relative;
    border: 1px solid transparent;
}

.mini-entry-text {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mini-entry:hover {
    opacity: 0.8;
    z-index: 10;
}

/* Mini Entry ハイライト */
.mini-entry.target-highlight-mini-active {
    border: 2px solid var(--highlight-active) !important;
    box-shadow: 0 0 5px rgba(245, 158, 11, 0.3);
}

.mini-entry.target-highlight-mini-done {
    border: 2px solid var(--highlight-done) !important;
}

.completed-line {
    opacity: 0.6;
    text-decoration: line-through;
    background-color: #f1f5f9 !important;
    border-left-color: #94a3b8 !important;
    color: #94a3b8;
}

/* Headers */
.grid-header {
    background-color: #f8fafc;
    font-weight: 700;
    text-align: center;
    padding: 8px;
    font-size: 0.9rem;
    border-bottom: none !important;
}

.day-number {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 4px;
    text-align: right;
    padding-right: 4px;
}

.fc-event-normal {
    opacity: 0.6;
    border: 1px solid #ddd !important;
    filter: grayscale(80%);
}

.fc-event-highlight {
    background-color: var(--legal-accent) !important;
    border: 2px solid #d63384 !important;
    color: #fff !important;
    opacity: 1;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    transform: scale(1.02);
    z-index: 10;
}

.task-card-fixed {
    border-left: 4px solid #0d6efd;
}

.task-card-free {
    border-left: 4px solid #198754;
}

/* List Card Highlight */
.task-card-item {
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

.target-highlight-list-active {
    border: 2px solid var(--highlight-active) !important;
    border-left-width: 6px !important;
    background-color: #fff !important;
    transform: translateX(-2px);
}

.target-highlight-list-done {
    border: 2px solid var(--highlight-done) !important;
    border-left-width: 6px !important;
    background-color: #f0fdfa !important;
}

/* ============================================================
   7. トースト通知 (Toast)
   ============================================================ */
.toast-container-majestic {
    position: fixed;
    top: 5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    pointer-events: none;
    white-space: pre-wrap;
}

.toast-majestic {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    min-width: 240px;
    max-width: 400px;
    transition: transform 0.2s ease;
    animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.toast-success {
    background-color: #10b981;
}

.toast-danger {
    background-color: #ef4444;
}

.toast-warning {
    background-color: #f59e0b;
}

.toast-deleted {
    background-color: #495057;
}

.toast-info {
    background-color: #3b82f6;
}

/* ============================================================
   8. アニメーション & ユーティリティ (Animations & Utilities)
   ============================================================ */
.animate-fade {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-refined {
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
}

.cursor-pointer {
    cursor: pointer;
}

.transition-all {
    transition: all 0.2s ease;
}

.opacity-60 {
    opacity: 0.6;
}

/* テーブルのホバー色を少し明るいグレー（#f8fafc）に統一 */
.table-hover-custom tbody tr:hover td {
    background-color: #f8fafc !important;
}

.status-badge {
    display: inline-block;
    min-width: 85px;
    text-align: center;
}

/* ツールチップ (Tooltip Fixed) */
.majestic-tooltip {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    visibility: hidden;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 99999;
    padding: 0;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    margin-top: 5px;
}

.tooltip-header {
    padding: 8px 12px;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
}

.tooltip-body {
    padding: 10px;
    font-size: 0.85rem;
    color: #334155;
    white-space: normal;
    text-align: left;
}

.entry-card:hover .majestic-tooltip,
.schedule-entry-card:hover .majestic-tooltip,
.mini-entry:hover .majestic-tooltip {
    visibility: visible;
    opacity: 1;
}

/* サジェストドロップダウン */
.suggest-container {
    position: relative;
    width: 100%;
}

.suggest-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 2000;
    width: 100%;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.08);
    list-style: none;
    padding: 0.5rem 0;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

    .suggest-dropdown li {
        padding: 0.7rem 1.2rem;
        cursor: pointer;
    }

        .suggest-dropdown li:hover {
            background-color: var(--legal-bg-light);
        }

/* ホバー時の浮き上がりエフェクト（汎用） */
.shadow-hover {
    transition: all 0.2s ease;
}

    .shadow-hover:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(0,0,0,0.08) !important;
    }

/* カラーピッカー (Color Picker) */
.color-picker-wrapper {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.color-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

    .color-circle.selected {
        transform: scale(1.1);
        box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--legal-accent);
    }

/* ============================================================
   9. ダッシュボード & その他専用ユーティリティ
   ============================================================ */
/* 太い左ボーダー（サマリーカード用） */
.border-start-primary-thick {
    border-left: 4px solid var(--legal-interactive) !important;
}

.border-start-danger-thick {
    border-left: 4px solid #ef4444 !important;
}

.border-start-warning-thick {
    border-left: 4px solid #f59e0b !important;
}

.border-start-success-thick {
    border-left: 4px solid #10b981 !important;
}

/* スクロール可能なテーブルコンテナ */
.ledger-table-container {
    max-height: calc(100vh - 350px);
    overflow-y: auto;
}

.invoice-table-container {
    max-height: 300px;
    overflow-y: auto;
}

.text-truncate-250 {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.checkbox-lg {
    transform: scale(1.2);
}

.welcome-icon-large {
    font-size: 6rem;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.05));
}
