/**
 * Diagram Viewer - Shared CSS
 * For use across all diagram viewers (tort, public law, etc.)
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    overflow: hidden;
}

/* Prevent flash of unstyled content while JavaScript loads */
body:not(.loaded) {
    visibility: hidden;
}

.container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 280px;
    background: #2d2d2d;
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid #444;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    margin-bottom: 20px;
}

.home-button {
    display: inline-block;
    padding: 8px 12px;
    background: #3d3d3d;
    border: 1px solid #555;
    border-radius: 6px;
    color: #ffffff;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
    margin-bottom: 15px;
}

.home-button:hover {
    background: #4d4d4d;
}

.sidebar h1 {
    font-size: 18px;
    margin-bottom: 0;
    color: #ffffff;
}

.nav-list {
    flex: 1;
    overflow-y: auto;
}

.sidebar-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #444;
    font-size: 12px;
    color: #888;
    text-align: center;
}

.nav-item {
    padding: 12px;
    margin-bottom: 8px;
    background: #3d3d3d;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
}

.nav-item:hover {
    background: #4d4d4d;
}

.nav-item.active {
    background: #0066cc;
}

.custom-link {
    display: block;
    padding: 12px;
    margin-bottom: 15px;
    background: #3d3d3d;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    text-align: center;
    text-decoration: none;
    color: #ffffff;
}

.custom-link:hover {
    background: #4d4d4d;
}

.viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
}

.toolbar {
    padding: 15px 20px;
    background: #2d2d2d;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.toolbar h2 {
    flex: 1;
    font-size: 18px;
    color: #ffffff;
}

.toolbar button {
    padding: 8px 16px;
    background: #3d3d3d;
    border: 1px solid #555;
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.toolbar button:hover {
    background: #4d4d4d;
}

.toolbar button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-buttons {
    display: flex;
    gap: 10px;
}

.diagram-container {
    flex: 1;
    overflow: hidden;
    background: #ffffff;
    position: relative;
}

.diagram-wrapper {
    display: none;
    width: 100%;
    height: 100%;
}

.diagram-wrapper.active {
    display: block;
}

.diagram-wrapper img,
.diagram-wrapper svg {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    margin: 0 auto;
}

/* Enable text selection when in text mode */
.diagram-wrapper svg * {
    user-select: none;
}

body.text-selection-mode .diagram-wrapper svg * {
    user-select: text;
    cursor: text !important;
}

/* Search highlights - using mark elements for precise text highlighting */
mark.search-highlight-mark {
    background-color: #ffeb3b;
    color: inherit;
    padding: 1px 0;
    border-radius: 2px;
}

mark.search-highlight-mark.search-highlight-active {
    background-color: #ff9800;
    font-weight: bold;
}

/* Search box */
.search-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 400px;
    margin-right: 20px;
}

.search-input {
    flex: 1;
    padding: 6px 10px;
    background: #3d3d3d;
    border: 1px solid #555;
    border-radius: 6px;
    color: #ffffff;
    font-size: 14px;
    outline: none;
}

.search-input:focus {
    border-color: #0066cc;
}

.search-nav {
    display: flex;
    gap: 4px;
}

.search-count {
    padding: 6px 10px;
    background: #3d3d3d;
    border-radius: 6px;
    font-size: 13px;
    color: #888;
    min-width: 50px;
    text-align: center;
}

.zoom-info {
    padding: 6px 12px;
    background: #3d3d3d;
    border-radius: 6px;
    font-size: 14px;
    color: #ffffff;
    min-width: 50px;
    text-align: center;
}

.zoom-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 200px;
    flex-shrink: 0;
}

.zoom-slider {
    width: 120px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #555;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #0066cc;
    border-radius: 50%;
    cursor: pointer;
}

.zoom-slider::-webkit-slider-thumb:hover {
    background: #0077ee;
}

.zoom-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #0066cc;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.zoom-slider::-moz-range-thumb:hover {
    background: #0077ee;
}

/* Mobile menu toggle button */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    background: #2d2d2d;
    border: 1px solid #555;
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #ffffff;
    border-radius: 1px;
    transition: all 0.3s;
}

.menu-toggle:hover {
    background: #3d3d3d;
}

.menu-toggle.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .sidebar-header {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }

    .home-button {
        order: -1;
        margin-bottom: 15px;
    }

    .sidebar h1 {
        align-self: flex-start;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        width: 280px;
    }

    .sidebar.mobile-open {
        left: 0;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .viewer {
        margin-left: 0;
    }

    .toolbar {
        padding: 10px 12px;
        padding-left: 65px; /* Make room for hamburger menu */
        flex-wrap: wrap;
        gap: 8px;
    }

    .toolbar h2 {
        font-size: 14px;
        width: 100%;
        order: -1;
        margin-bottom: 8px;
    }

    /* Hide search on mobile - takes too much space */
    .search-container {
        display: none;
    }

    .nav-buttons {
        order: 1;
        gap: 6px;
    }

    .zoom-slider-container {
        width: auto;
        flex: 1;
        min-width: 120px;
        order: 2;
    }

    .zoom-slider {
        width: 70px;
    }

    .zoom-info {
        font-size: 13px;
        padding: 6px 8px;
        min-width: 45px;
    }

    #reset-zoom {
        order: 3;
        padding: 8px 10px;
        font-size: 12px;
    }

    .toolbar button {
        padding: 8px 10px;
        font-size: 12px;
    }

    /* Touch-friendly nav items */
    .nav-item {
        padding: 14px 12px;
        font-size: 15px;
        -webkit-tap-highlight-color: transparent;
    }

    .home-button {
        padding: 10px 14px;
        font-size: 15px;
    }
}

/* Very small phones */
@media screen and (max-width: 400px) {
    .toolbar {
        padding: 8px 10px;
        padding-left: 60px;
    }

    .toolbar h2 {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .toolbar button {
        padding: 6px 8px;
        font-size: 11px;
    }

    .nav-buttons {
        gap: 4px;
    }

    .nav-buttons button {
        padding: 7px 8px;
    }

    .zoom-slider-container {
        min-width: 100px;
    }

    .zoom-slider {
        width: 50px;
    }

    .zoom-info {
        padding: 5px 6px;
        font-size: 12px;
        min-width: 40px;
    }

    #reset-zoom {
        padding: 6px 8px;
    }

    .menu-toggle {
        width: 40px;
        height: 40px;
        top: 12px;
        left: 12px;
    }

    .menu-toggle span {
        width: 20px;
    }
}

/* Landscape mobile */
@media screen and (max-height: 500px) and (max-width: 900px) {
    .toolbar {
        padding: 6px 10px;
        padding-left: 60px;
    }

    .toolbar h2 {
        font-size: 13px;
        margin-bottom: 6px;
    }

    /* Hide search on landscape mobile too */
    .search-container {
        display: none;
    }

    .sidebar {
        width: 240px;
        left: -240px;
        padding: 15px;
    }

    .nav-item {
        padding: 10px;
        font-size: 14px;
        margin-bottom: 6px;
    }

    .sidebar h1 {
        font-size: 16px;
    }
}
