/**
 * GilGamez Engine — Modal Unsaved Changes Guard Stylesheet
 * Enforces Rule #1, Rule #2, and Rule #6 (5-Tier Responsive Architecture).
 */

.modal-guard-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 6, 16, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100005;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    animation: modalGuardFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalGuardFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-guard-confirm-dialog {
    width: 100%;
    max-width: 440px;
    background: linear-gradient(145deg, #131828 0%, #0d121f 100%);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75), 0 0 32px rgba(239, 68, 68, 0.15);
    text-align: center;
    box-sizing: border-box;
    animation: modalGuardPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalGuardPopIn {
    from { transform: scale(0.92) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-guard-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 16px auto;
    color: #ef4444;
}

.modal-guard-title {
    font-size: 17px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0 0 8px 0;
}

.modal-guard-message {
    font-size: 13.5px;
    color: #94a3b8;
    line-height: 1.55;
    margin: 0 0 22px 0;
}

.modal-guard-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.modal-guard-btn-keep {
    flex: 1;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f8fafc;
    cursor: pointer;
    transition: all 0.18s ease;
}

.modal-guard-btn-keep:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
}

.modal-guard-btn-discard {
    flex: 1;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #ffffff;
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.modal-guard-btn-discard:hover {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45);
}

/* Subtle Shake Animation for Accidental Outside Click */
.modal-dialog-shake {
    animation: modalDialogShakeAnim 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes modalDialogShakeAnim {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(3px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

@media (max-width: 480px) {
    .modal-guard-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }
    .modal-guard-btn-keep,
    .modal-guard-btn-discard {
        width: 100%;
    }
}
/**
 * GilGamez Core Engine — Interactive Documentation Modal Stylesheet
 * Enforces Rule #1 (Technology Separation), Rule #2 (Centralized Engine), Rule #6 (5-Tier Responsive).
 */

.doc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 7, 18, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s ease;
}

.doc-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.doc-modal-container {
    width: 100%;
    max-width: 1180px;
    height: 88vh;
    max-height: 880px;
    background: #0b0f19;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    box-shadow: 0 28px 64px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(99, 102, 241, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96) translateY(12px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.doc-modal-overlay.active .doc-modal-container {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.doc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(15, 23, 42, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 16px;
    flex-shrink: 0;
}

.doc-modal-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.doc-modal-badge-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    flex-shrink: 0;
}

.doc-modal-title-wrap {
    min-width: 0;
}

.doc-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-modal-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

.doc-modal-category-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
    font-size: 11px;
    font-weight: 600;
}

.doc-modal-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.doc-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.doc-search-input {
    width: 220px;
    height: 34px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 0 10px 0 32px;
    font-size: 12.5px;
    color: #f1f5f9;
    outline: none;
    transition: all 0.2s ease;
}

.doc-search-input:focus {
    width: 280px;
    background: rgba(15, 23, 42, 0.95);
    border-color: #6366f1;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
}

.doc-search-icon {
    position: absolute;
    left: 10px;
    font-size: 13px;
    color: #94a3b8;
    pointer-events: none;
}

.doc-modal-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.doc-modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
    color: #ffffff;
    transform: rotate(90deg);
}

/* Modal Body Layout: Sidebar + Main Content */
.doc-modal-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Document Guides Sidebar */
.doc-modal-sidebar {
    width: 280px;
    background: rgba(10, 14, 26, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    overflow-y: auto;
    padding: 16px 12px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.doc-sidebar-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #64748b;
    padding: 8px 10px 4px 10px;
    margin-top: 8px;
}

.doc-sidebar-section-title:first-child {
    margin-top: 0;
}

.doc-sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    color: #94a3b8;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    border: 1px solid transparent;
    user-select: none;
}

.doc-sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #f1f5f9;
}

.doc-sidebar-nav-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18) 0%, rgba(79, 70, 229, 0.12) 100%);
    border-color: rgba(99, 102, 241, 0.4);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.doc-sidebar-item-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.doc-sidebar-item-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Document Main Content Pane */
.doc-modal-content-pane {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px;
    background: #0b0f19;
    color: #e2e8f0;
    font-size: 14px;
    line-height: 1.7;
}

/* Markdown Rendered Typography */
.doc-markdown h1 {
    font-size: 22px;
    font-weight: 800;
    color: #f8fafc;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.doc-markdown h2 {
    font-size: 17px;
    font-weight: 700;
    color: #f1f5f9;
    margin: 28px 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-markdown h3 {
    font-size: 14.5px;
    font-weight: 600;
    color: #cbd5e1;
    margin: 20px 0 8px 0;
}

.doc-markdown p {
    margin: 0 0 14px 0;
    color: #cbd5e1;
}

/* Table of Contents & Ordered / Unordered Lists */
.doc-markdown .doc-ordered-list,
.doc-markdown .doc-unordered-list,
.doc-markdown ul,
.doc-markdown ol {
    margin: 14px 0 20px 0;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.doc-markdown .doc-ordered-list {
    counter-reset: doc-counter;
}

.doc-markdown .doc-ordered-list > li.doc-list-item {
    counter-increment: doc-counter;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    color: #e2e8f0;
    font-size: 13.5px;
    line-height: 1.5;
}

.doc-markdown .doc-ordered-list > li.doc-list-item::before {
    content: counter(doc-counter);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(79, 70, 229, 0.2) 100%);
    border: 1px solid rgba(99, 102, 241, 0.45);
    border-radius: 6px;
    color: #c7d2fe;
    font-size: 11px;
    font-weight: 700;
    font-family: monospace;
    flex-shrink: 0;
    margin-top: 1px;
}

.doc-markdown .doc-ordered-list > li.doc-list-item:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.35);
    transform: translateX(3px);
}

.doc-markdown .doc-unordered-list > li.doc-list-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 4px 6px;
    color: #cbd5e1;
    font-size: 13.5px;
    line-height: 1.6;
}

.doc-markdown .doc-unordered-list > li.doc-list-item::before {
    content: '▸';
    color: #818cf8;
    font-size: 14px;
    line-height: 1.3;
    flex-shrink: 0;
}

/* Links inside Documentation */
.doc-anchor-link {
    color: #818cf8;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.doc-anchor-link:hover {
    color: #c7d2fe;
    text-decoration: underline;
}

.doc-external-link {
    color: #38bdf8;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: color 0.18s ease;
}

.doc-external-link:hover {
    color: #7dd3fc;
    text-decoration: underline;
}

.doc-ext-icon {
    font-size: 11px;
    opacity: 0.8;
}

.doc-internal-switch-link {
    color: #a855f7;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.18s ease;
}

.doc-internal-switch-link:hover {
    color: #c084fc;
    text-decoration: underline;
}

/* Heading Jump Highlight */
.doc-heading-highlight {
    animation: docHeadingPulse 1.8s ease forwards;
}

@keyframes docHeadingPulse {
    0% {
        background-color: rgba(99, 102, 241, 0.35);
        border-radius: 6px;
        padding: 4px 8px;
        margin-left: -8px;
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    }
    100% {
        background-color: transparent;
        border-radius: 0;
        padding: 0;
        margin-left: 0;
        box-shadow: none;
    }
}

.doc-markdown hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 24px 0;
}

/* Acceptable Values & Documentation Tables */
.doc-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 24px 0;
    font-size: 13px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.doc-markdown th {
    background: rgba(30, 41, 59, 0.85);
    color: #f8fafc;
    font-weight: 700;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.doc-markdown td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    vertical-align: top;
}

.doc-markdown tr:last-child td {
    border-bottom: none;
}

.doc-markdown tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Fenced Code Blocks with Copy Button */
.doc-code-block-container {
    position: relative;
    margin: 14px 0 20px 0;
    border-radius: 10px;
    background: #060913;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.doc-code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 11px;
    color: #94a3b8;
    font-family: monospace;
}

.doc-code-copy-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.doc-code-copy-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.5);
    color: #ffffff;
}

.doc-code-copy-btn.copied {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.5);
    color: #34d399;
}

.doc-code-content {
    margin: 0;
    padding: 14px 16px;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 12.5px;
    color: #38bdf8;
    line-height: 1.6;
    overflow-x: auto;
}

.doc-markdown code:not(pre code) {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    padding: 2px 6px;
    border-radius: 5px;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 12px;
}

/* Callout Alerts */
.doc-alert {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    margin: 16px 0;
    border: 1px solid transparent;
}

.doc-alert-icon {
    font-size: 18px;
    line-height: 1.2;
    flex-shrink: 0;
}

.doc-alert-body {
    flex: 1;
    font-size: 13px;
    line-height: 1.5;
}

.doc-alert-note {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}

.doc-alert-tip {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
}

.doc-alert-important {
    background: rgba(168, 85, 247, 0.08);
    border-color: rgba(168, 85, 247, 0.25);
    color: #d8b4fe;
}

.doc-alert-warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
    color: #fcd34d;
}

.doc-alert-caution {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

/* Topbar Docs Trigger Button */
.topbar-doc-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.topbar-doc-trigger-btn:hover {
    background: rgba(99, 102, 241, 0.22);
    border-color: rgba(99, 102, 241, 0.45);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

/* Inline Section Guide Trigger Badge */
.doc-section-badge-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
}

.doc-section-badge-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    color: #ffffff;
}

/* Responsive Rules (Rule #6) */
@media (max-width: 900px) {
    .doc-modal-sidebar {
        display: none;
    }
    .doc-modal-content-pane {
        padding: 20px 24px;
    }
    .doc-search-input {
        width: 160px;
    }
    .doc-search-input:focus {
        width: 200px;
    }
}

@media (max-width: 600px) {
    .doc-modal-overlay {
        padding: 8px;
    }
    .doc-modal-container {
        height: 94vh;
        border-radius: 14px;
    }
    .doc-modal-header {
        padding: 12px 16px;
    }
    .doc-modal-content-pane {
        padding: 16px;
    }
    .doc-search-input-wrap {
        display: none;
    }
}
