/* === MG ToS Layout === */
:root {
    --mg-primary: #752b03;
    --mg-dark: #1a1a2e;
    --mg-text: #333333;
    --mg-text-light: #888888;
    --mg-bg: #ffffff;
    --mg-border: #e5e5e5;
    --mg-sidebar-width: 260px;
    --mg-sidebar-bg: #fafafa;
}

/* Scoped reset */
.mg-tos-container,
.mg-tos-container * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Helvetica, Arial, sans-serif;
}

/* Container: sidebar + content */
.mg-tos-container {
    display: flex;
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
}

/* === SIDEBAR === */
.mg-tos-sidebar {
    width: var(--mg-sidebar-width);
    flex-shrink: 0;
    background: var(--mg-sidebar-bg);
    border-right: 1px solid var(--mg-border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 10;
}

.mg-tos-sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--mg-border);
}
.mg-tos-sidebar-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--mg-text-light);
}

/* Nav list */
.mg-tos-nav {
    list-style: none;
    margin: 0;
    padding: 12px 0;
}
.mg-tos-nav li { margin: 0; }
.mg-tos-nav-link {
    display: block;
    padding: 8px 16px;
    color: var(--mg-text);
    text-decoration: none;
    font-size: 13px;
    line-height: 1.4;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}
.mg-tos-nav-link:hover {
    background: rgba(117, 43, 3, 0.05);
    color: var(--mg-primary);
}
.mg-tos-nav-link.active {
    color: var(--mg-primary);
    font-weight: 600;
    border-left-color: var(--mg-primary);
    background: rgba(117, 43, 3, 0.06);
}

/* Sub-nav (subsections) */
.mg-tos-nav-sub {
    list-style: none;
    margin: 0;
    padding: 0 0 0 12px;
}
.mg-tos-nav-sub a {
    display: block;
    font-size: 12px;
    padding: 5px 16px;
    color: var(--mg-text-light);
    text-decoration: none;
    transition: color 0.15s ease;
}
.mg-tos-nav-sub a:hover {
    color: var(--mg-primary);
}

/* Sidebar collapse */
.mg-tos-container[data-sidebar-collapsed="true"] .mg-tos-sidebar {
    transform: translateX(-100%);
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.mg-tos-container[data-sidebar-collapsed="true"] .mg-tos-content {
    max-width: 100%;
}

/* Toggle button */
.mg-tos-toggle {
    display: none;  /* Hidden on desktop by default */
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 20;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--mg-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 20px;
    transition: transform 0.2s ease;
}
.mg-tos-toggle:hover { transform: scale(1.1); }
.mg-tos-toggle-icon::before { content: '\2630'; /* hamburger */ }
.mg-tos-container[data-sidebar-collapsed="false"] .mg-tos-toggle-icon::before {
    content: '\2715'; /* close */
}

/* === CONTENT === */
.mg-tos-content {
    flex: 1;
    min-width: 0;
    padding: 40px 48px;
    max-width: calc(100% - var(--mg-sidebar-width));
}

.mg-tos-header {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--mg-border);
}
.mg-tos-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--mg-dark);
    margin: 0 0 12px 0;
}
.mg-tos-meta {
    display: flex;
    gap: 20px;
    color: var(--mg-text-light);
    font-size: 13px;
    align-items: center;
}
.mg-tos-version {
    background: rgba(117, 43, 3, 0.08);
    color: var(--mg-primary);
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
}

/* Sections */
.mg-tos-section {
    margin-bottom: 36px;
    scroll-margin-top: 20px;  /* Offset for sticky header if any */
}
.mg-tos-section h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--mg-dark);
    margin: 0 0 16px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--mg-border);
}
.mg-tos-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--mg-text);
    margin: 24px 0 12px 0;
}
.mg-tos-subsection {
    margin-bottom: 20px;
    scroll-margin-top: 20px;
}
.mg-tos-section-body {
    font-size: 14px;
    line-height: 1.75;
    color: var(--mg-text);
}
.mg-tos-section-body p { margin: 0 0 12px 0; }
.mg-tos-section-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 13px;
}
.mg-tos-section-body th,
.mg-tos-section-body td {
    padding: 8px 12px;
    border: 1px solid var(--mg-border);
    text-align: left;
}
.mg-tos-section-body th {
    background: var(--mg-sidebar-bg);
    font-weight: 600;
}

/* Error state */
.mg-content-error {
    text-align: center;
    padding: 48px 20px;
    color: var(--mg-text-light);
    background: #fafafa;
    border-radius: 12px;
    border: 1px dashed var(--mg-border);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .mg-tos-container { flex-direction: column; }

    .mg-tos-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        transform: translateX(-100%);
        z-index: 100;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    .mg-tos-container[data-sidebar-collapsed="false"] .mg-tos-sidebar {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .mg-tos-toggle { display: flex; align-items: center; justify-content: center; }
    .mg-tos-content {
        max-width: 100%;
        padding: 24px 16px;
    }
    .mg-tos-title { font-size: 22px; }

    /* Sidebar overlay - mobile only */
    .mg-tos-container[data-sidebar-collapsed="false"] .mg-tos-overlay {
        display: block;
    }
}

/* Overlay base styles (hidden by default, shown only on mobile via media query above) */
.mg-tos-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}
