/*
 * ManualDog Admin Styles
 * v1.0.0
 * This stylesheet handles the custom UI for the plugin's index and viewer pages.
 */

/* ==========================================================================
   1. Index Page Styles (List of all manuals)
   ========================================================================== */

.manualdog-index-page .manualdog-page-wrapper {
    background-color: #ffffff;
    margin-top: 20px;
    padding: 25px 40px;
    border: 1px solid #ccd0d4;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.manualdog-index-page .manualdog-page-header { text-align: center; margin-bottom: 40px; padding-bottom: 25px; border-bottom: 1px solid #eee; }
.manualdog-index-page .manualdog-page-header h1 { font-size: 2.2em; }
.manualdog-index-page .manualdog-manual-list { list-style: none; padding-left: 0; margin: 0; }
.manualdog-index-page .manualdog-manual-list a { font-size: 1.2em; text-decoration: none; display: block; padding: 10px 15px; border-radius: 4px; transition: background-color 0.2s, color 0.2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.manualdog-index-page .manualdog-manual-list a:hover { background-color: #f0f6fc; color: #005a87; }

/* ==========================================================================
   2. Viewer Page (2-Column Layout) Styles
   ========================================================================== */

/* Fullscreen adjustment */
body.toplevel_page_manualdog_manual_index .wrap.manualdog-viewer-fullscreen,
body.manuals_page_manualdog_manual_viewer .wrap.manualdog-viewer-fullscreen { margin-left: -20px; }
.manualdog-viewer-fullscreen { display: flex; height: calc(100vh - 32px); overflow: hidden; position: relative; }

/* --- 2.1 Sidebar (Left Column) --- */
.manualdog-viewer-sidebar { width: 280px; background-color: #f0f0f1; border-right: 1px solid #dcdcde; display: flex; flex-direction: column; height: 100%; }
.manualdog-sidebar-header { padding: 15px 20px; border-bottom: 1px solid #dcdcde; flex-shrink: 0; }
.manualdog-sidebar-header a { display: flex; align-items: center; text-decoration: none; color: #1d2327; font-size: 16px; font-weight: 600; }
.manualdog-sidebar-header img { width: 36px; height: 36px; margin-right: 12px; }
.manualdog-sidebar-nav { overflow-y: auto; padding: 15px 0; flex-grow: 1; }
.manualdog-sidebar-nav-list { list-style: none; padding-left: 20px; margin: 0; }
.manualdog-sidebar-nav-list a { display: block; padding: 8px 15px; text-decoration: none; color: #444; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.manualdog-sidebar-nav-list .current-manual > a,
.manualdog-sidebar-nav-list a:hover { background-color: #fff; color: #005a87; }
.manualdog-sidebar-nav-list .current-manual > a { font-weight: 600; }
.manualdog-sidebar-nav-list .level-1, .manualdog-sidebar-nav-list .level-2 { padding-left: 20px; }

/* --- 2.2 Main Content (Right Column) --- */
.manualdog-viewer-main { flex-grow: 1; background-color: #ffffff; display: flex; flex-direction: column; height: 100%; overflow-y: auto; transition: opacity 0.3s; }
.manualdog-main-header { padding: 20px 25px; border-bottom: 1px solid #eee; display: flex; justify-content: flex-start; align-items: center; }
.manualdog-main-title { font-size: 1.8em; margin: 0 15px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; flex-grow: 1; }
.manualdog-main-header .page-title-action { margin-left: auto; }
.manualdog-main-content { padding: 25px; font-size: 16px; line-height: 1.8; flex-grow: 1; max-width: 840px; }
.manualdog-main-content h2, .manualdog-main-content h3 { margin-top: 2.5em; margin-bottom: 1em; }
.manualdog-main-content img { max-width: 100%; height: auto; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,.08); }

/* --- 2.3 Pager Footer (Previous/Next) --- */
.manualdog-main-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 25px;
    margin-top: auto;
    border-top: 1px solid #eee;
}
.manualdog-main-footer .pager-prev,
.manualdog-main-footer .pager-next {
    min-width: 0; /* Important for grid item truncation */
}
.manualdog-main-footer .pager-prev a,
.manualdog-main-footer .pager-next a {
    display: block;
    border: 1px solid #dcdcde;
    padding: 15px;
    border-radius: 8px;
    text-decoration: none;
    color: #1d2327;
    transition: background-color 0.2s;
    height: 100%;
}
.manualdog-main-footer .pager-prev a:hover,
.manualdog-main-footer .pager-next a:hover {
    background-color: #f6f7f7;
}
.manualdog-main-footer .pager-prev a strong,
.manualdog-main-footer .pager-next a strong {
    display: block;
    font-size: 12px;
    color: #646970;
    margin-bottom: 4px;
}
/* This is the final fix for title truncation */
.manualdog-main-footer .pager-prev a span,
.manualdog-main-footer .pager-next a span {
    font-size: 15px;
    font-weight: 500;
    display: block; /* Must be block for ellipsis to work */
    white-space: nowrap; /* Prevent wrapping */
    overflow: hidden; /* Hide overflowing text */
    text-overflow: ellipsis; /* Add ... */
}
.manualdog-main-footer .pager-next { text-align: right; }

/* ==========================================================================
   3. Mobile Responsive Styles
   ========================================================================== */
.manualdog-sidebar-toggle { display: none; }
@media screen and (max-width: 782px) {
    body.toplevel_page_manualdog_manual_index .wrap.manualdog-viewer-fullscreen,
    body.manuals_page_manualdog_manual_viewer .wrap.manualdog-viewer-fullscreen { margin-left: -10px; }
    .manualdog-viewer-fullscreen { flex-direction: column; height: auto; min-height: calc(100vh - 46px); }
    .manualdog-viewer-sidebar { position: absolute; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform 0.3s ease; z-index: 100; width: 280px; }
    .manualdog-viewer-fullscreen.sidebar-is-open .manualdog-viewer-sidebar { transform: translateX(0); box-shadow: 2px 0 10px rgba(0,0,0,0.1); }
    .manualdog-viewer-fullscreen.sidebar-is-open .manualdog-viewer-main { opacity: 0.5; pointer-events: none; }
    .manualdog-viewer-main { width: 100%; }
    .manualdog-main-header { padding: 15px; }
    .manualdog-main-title { font-size: 1.4em; margin: 0 10px; }
    .manualdog-main-content { padding: 20px; font-size: 15px; }
    .manualdog-main-footer { padding: 20px; grid-template-columns: 1fr; }
    .manualdog-sidebar-toggle { display: inline-flex; background: none; border: none; color: #50575e; padding: 5px; cursor: pointer; align-items: center; justify-content: center; }
    .manualdog-sidebar-toggle .dashicons { font-size: 28px; line-height: 1; }
}