/**
 * Secure Document Library – Front-end Styles
 *
 * @package SecureDocumentLibrary
 */

/* ============================================
   Container & Layout
   ============================================ */
.sdl-container {
    width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, sans-serif;
    color: #333;
    line-height: 1.5;
    box-sizing: border-box;
}

.sdl-container *, .sdl-container *::before, .sdl-container *::after {
    box-sizing: border-box;
}

/* Header */
.sdl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e5e5;
}

.sdl-header-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.sdl-header-icon { flex-shrink: 0; }

.sdl-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #222;
}

.sdl-subtitle {
    margin: 2px 0 0;
    font-size: 14px;
    color: #777;
}

/* Search */
.sdl-search { position: relative; flex-shrink: 0; }

.sdl-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.sdl-search-input {
    padding: 10px 14px 10px 38px;
    width: 260px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sdl-search-input:focus {
    outline: none;
    border-color: #F4C430;
    box-shadow: 0 0 0 3px rgba(244, 196, 48, 0.15);
}

/* Body: sidebar + content */
.sdl-body {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* ============================================
   Sidebar
   ============================================ */
.sdl-sidebar { flex: 0 0 280px; min-width: 0; }

/* Fix #2: Remove list dots */
.sdl-cat-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sdl-cat-list li {
    list-style: none;
    margin-bottom: 2px;
}

.sdl-cat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: #f9f9f9;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    text-align: left;
    transition: background 0.15s, transform 0.1s;
    /* Fix #6: border-left is now set inline per-button from PHP */
}

.sdl-cat-btn:hover { background: #f0eee6; }

.sdl-cat-btn.active {
    background: #FFF8DC;
    font-weight: 600;
    box-shadow: inset 3px 0 0 #F4C430;
}

.sdl-cat-btn span {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sdl-cat-icon { flex-shrink: 0; }

.sdl-chevron {
    flex-shrink: 0;
    opacity: 0.4;
    transition: transform 0.2s, opacity 0.2s;
}

.sdl-cat-btn.active .sdl-chevron {
    transform: rotate(90deg);
    opacity: 0.7;
}

/* ============================================
   Main Content / Tree
   ============================================ */
.sdl-content {
    flex: 1; min-width: 0;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 20px;
    min-height: 360px;
}

.sdl-placeholder {
    color: #999;
    text-align: center;
    padding: 60px 20px;
    font-size: 15px;
}

/* Tree category title */
.sdl-tree-category-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 12px;
    color: #333;
}

/* Reset all lists inside tree */
.sdl-tree ul,
.sdl-tree ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sdl-tree li {
    list-style: none;
}

/* Document list indented inside month folder — must override reset above */
.sdl-tree ul.sdl-doc-list {
    margin: 4px 0 8px 5%;
    padding: 0;
    list-style: none;
}

/* <details>/<summary> tree */
.sdl-tree details {
    margin-left: 24px;
}

/* Subcategory level — slight indent from parent title */
.sdl-tree details[data-level="subcategory"] {
    margin-left: 8px;
}

/* Year level inside subcategory gets normal indent */
.sdl-tree details[data-level="year"] {
    margin-left: 24px;
}

/* Top-level years (no subcategories) — less indent */
.sdl-tree > details[data-level="year"] {
    margin-left: 8px;
}

.sdl-tree summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #444;
    list-style: none;
    user-select: none;
    transition: background 0.15s;
}

.sdl-tree summary::-webkit-details-marker { display: none; }
.sdl-tree summary::marker { display: none; content: ''; }
.sdl-tree summary:hover { background: #f0eee6; }

.sdl-tree summary .sdl-toggle {
    display: inline-flex;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.sdl-tree details[open] > summary .sdl-toggle {
    transform: rotate(90deg);
}

.sdl-folder-svg { flex-shrink: 0; }

/* Subcategory level */
.sdl-tree summary[data-level="subcategory"] {
    font-size: 16px;
    font-weight: 700;
}

.sdl-tree summary[data-level="year"] { font-size: 15px; font-weight: 600; }
.sdl-tree summary[data-level="month"] { font-size: 14px; font-weight: 500; }

.sdl-doc-item {
    margin-bottom: 2px;
    list-style: none;
}

.sdl-doc-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, transform 0.1s;
}

.sdl-doc-link:hover {
    background: #e8f4e8;
    transform: translateX(2px);
}

/* File type badges */
.sdl-file-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    min-width: 32px;
    text-align: center;
}

.sdl-file-badge-pdf  { background: #e74c3c; }
.sdl-file-badge-doc,
.sdl-file-badge-docx { background: #2b579a; }
.sdl-file-badge-xls,
.sdl-file-badge-xlsx { background: #217346; }
.sdl-file-badge-ppt,
.sdl-file-badge-pptx { background: #d24726; }
.sdl-file-badge-link { background: #6c5ce7; }

/* Alternating row tints */
.sdl-doc-link[data-index="0"] { background: rgba(144,238,144,0.12); }
.sdl-doc-link[data-index="1"] { background: rgba(173,216,230,0.15); }
.sdl-doc-link[data-index="2"] { background: rgba(221,160,221,0.12); }

/* External link indicator */
.sdl-external-icon {
    opacity: 0.4;
    flex-shrink: 0;
    margin-left: auto;
}

/* ============================================
   Search Results
   ============================================ */
.sdl-search-results { padding: 0; }
.sdl-sr-group { margin-bottom: 16px; }

.sdl-sr-group-title {
    font-size: 14px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}

.sdl-sr-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    transition: background 0.15s;
}

.sdl-sr-item:hover { background: #f5f5f5; }

.sdl-sr-item a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.sdl-sr-item a:hover { color: #D4A017; }

.sdl-sr-meta {
    font-size: 12px;
    color: #999;
    margin-left: auto;
}

.sdl-search-no-results {
    text-align: center;
    padding: 40px;
    color: #999;
}

.sdl-search-no-results svg { margin-bottom: 8px; opacity: 0.4; }

/* Loading spinner */
.sdl-loading {
    text-align: center;
    padding: 30px;
    color: #999;
}

.sdl-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #F4C430;
    border-radius: 50%;
    animation: sdl-spin 0.6s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes sdl-spin { to { transform: rotate(360deg); } }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .sdl-body { flex-direction: column; }
    .sdl-sidebar { flex: none; width: 100%; }

    .sdl-cat-list { display: flex; flex-wrap: wrap; gap: 6px; }
    .sdl-cat-list li { margin-bottom: 0; }

    .sdl-cat-btn {
        padding: 8px 12px;
        font-size: 13px;
        border-radius: 20px;
    }

    .sdl-cat-btn .sdl-chevron { display: none; }
}

@media (max-width: 768px) {
    .sdl-header { flex-direction: column; align-items: flex-start; }
    .sdl-search { width: 100%; }
    .sdl-search-input { width: 100%; }
    .sdl-content { padding: 14px; }
    .sdl-tree details { margin-left: 12px; }
    .sdl-doc-list { padding-left: 20px; }
    .sdl-title { font-size: 20px; }
}
