/* ===========================================
   Document Hub & Dashboard Layout
   =========================================== */

.documents-section {
    padding: 120px 5%;
    background: hsl(0, 0%, 100%);
}

.repo-dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
    align-items: start;
}

/* --- Sidebar Styling --- */

.repo-sidebar {
    position: sticky;
    top: 150px;
}

/* Mobile category dropdown wrapper (hidden on desktop) */
.mobile-category-control-group {
    display: none !important;
}

.sidebar-title {
    font-size: 0.75rem;
    letter-spacing: 2px;
    font-weight: 800;
    color: #94a3b8;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.document-filter-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 30px;
}

/* Desktop: show buttons, hide dropdown */
.filter-btn-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-select-group {
    display: none;
}

.doc-filter-btn {
    text-align: left;
    padding: 14px 18px;
    background: white;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-blue);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.doc-filter-btn.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
    box-shadow: 0 4px 12px rgba(0, 49, 80, 0.15);
}

.doc-filter-btn:hover:not(.active) {
    border-color: var(--secondary-gold);
    background: #fffdf5;
}

/* --- Custom UI Dropdown --- */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.custom-dropdown-trigger {
    width: 100%;
    padding: 14px 18px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-blue);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.custom-dropdown-trigger:hover {
    border-color: var(--secondary-gold);
    background: #fffdf5;
}

.custom-dropdown-trigger:focus-visible {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 49, 80, 0.08);
}

.custom-dropdown-trigger .trigger-arrow {
    font-size: 0.8rem;
    transition: transform 0.25s ease;
    color: var(--primary-blue);
}

.custom-dropdown.active .custom-dropdown-trigger .trigger-arrow {
    transform: rotate(180deg);
}

.custom-dropdown.active .custom-dropdown-trigger {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 49, 80, 0.08);
}

.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
}

.custom-dropdown.active .custom-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-dropdown-item {
    padding: 12px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.custom-dropdown-item:hover {
    background: #f1f5f9;
    color: var(--primary-blue);
}

.custom-dropdown-item.active {
    background: #f0f7ff;
    color: var(--primary-blue);
    font-weight: 700;
}

/* Tick mark for selected item */
.custom-dropdown-item.active::after {
    content: "\f00c";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 0.75rem;
    color: var(--primary-blue);
}

/* --- Filter Skeleton Loading --- */

.filter-skeleton {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-skeleton-item {
    height: 48px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.filter-skeleton-item.short {
    width: 70%;
}

@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.sidebar-info-box {
    background: #f1f5f9;
    padding: 20px;
    border-radius: 4px;
    display: flex;
    gap: 12px;
}

.sidebar-info-box i {
    color: var(--primary-blue);
    margin-top: 3px;
}

.sidebar-info-box p {
    font-size: 0.82rem;
    color: #64748b;
    line-height: 1.5;
}

/* --- Content Area & Search --- */

.repo-main-content {
    min-height: 800px;
    min-width: 0;
}

.repo-content-header {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-bottom: 50px;
}

.header-title-area .section-title {
    margin-bottom: 8px;
}

.section-subtitle {
    font-size: 0.95rem;
    color: #64748b;
    font-weight: 400;
}

.repo-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    background: white;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.search-container {
    flex: 1;
    max-width: 500px;
}

.search-input-group {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 1rem;
}

#doc-search {
    width: 100%;
    padding: 16px 16px 16px 50px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.95rem;
    color: var(--primary-blue);
    transition: all 0.3s ease;
}

#doc-search:focus {
    outline: none;
}

/* --- Filter Controls --- */

.filter-controls {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-range-group {
    min-width: 320px;
}

.control-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-wrapper {
    position: relative;
    min-width: 140px;
}

#sort-filter-wrapper {
    position: relative;
    min-width: 140px;
}

.select-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-blue);
    font-size: 0.8rem;
    pointer-events: none;
}

/* --- Date Range Filter --- */
.date-range-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 4px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.date-range-inputs:focus-within {
    background: white;
}

.date-range-inputs .input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.date-range-inputs input[type="date"] {
    border: none;
    background: transparent;
    padding: 8px 0;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-blue);
    cursor: pointer;
    min-width: 120px;
}

.date-range-inputs input[type="date"]:focus {
    outline: none;
}

.date-range-inputs input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.date-range-inputs input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.range-divider {
    font-size: 0.7rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    padding: 0 4px;
}

.filter-select,
select#sort-filter {
    width: 100%;
    padding: 12px 12px 12px 36px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-blue);
    cursor: pointer;
    appearance: none;
    transition: all 0.2s ease;
}

.filter-select:hover,
select#sort-filter:hover {
    border-color: var(--secondary-gold);
    background: white;
}

.filter-select:focus,
select#sort-filter:focus {
    outline: none;
}

/* --- Document Cards Grid --- */

.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.document-card {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 30px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border-radius: 4px;
}

.document-card:hover {
    border-color: var(--secondary-gold);
    box-shadow: 0 20px 40px rgba(0, 49, 80, 0.05);
    transform: translateY(-5px);
}

.doc-type-icon {
    font-size: 2.2rem;
    margin-bottom: 20px;
}

.doc-type-pdf {
    color: #ef4444;
}

.doc-type-docx {
    color: #3b82f6;
}

.doc-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary-blue);
    margin-bottom: 12px;
    line-height: 1.4;
}

.doc-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.doc-badge {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 4px 10px;
    background: #f1f5f9;
    color: #64748b;
    text-transform: uppercase;
}

.doc-badge.date {
    background: hsl(200, 95%, 95%);
    color: hsl(200, 95%, 30%);
}

/* --- Tag Badges --- */

.doc-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
}

.doc-tags-icon {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-right: 2px;
}

.doc-tag {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 10px;
    background: hsl(43, 100%, 95%);
    color: hsl(43, 80%, 35%);
    border: 1px solid hsl(43, 80%, 85%);
    border-radius: 20px;
    text-transform: lowercase;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
}

.doc-tag:hover {
    background: hsl(43, 80%, 88%);
    border-color: hsl(43, 80%, 70%);
}

.doc-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-action-primary,
.btn-action-outline {
    padding: 12px;
    text-align: center;
    text-decoration: none;
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    border-radius: 4px;
    width: 100%;
}

a.btn-action-primary {
    background: var(--primary-blue);
    color: white;
    border: 1px solid var(--primary-blue);
}

a.btn-action-primary:hover {
    background: var(--secondary-gold);
    border-color: var(--secondary-gold);
    color: var(--primary-blue);
}

a.btn-action-outline {
    background: transparent;
    color: var(--primary-blue);
    border: 1px solid #e2e8f0;
}

a.btn-action-outline:hover {
    border-color: var(--primary-blue);
    background: #f8fafc;
}

/* ===========================================
   Responsive — Tablet (≤1024px)
   =========================================== */

@media (max-width: 1024px) {
    .repo-dashboard-container {
        grid-template-columns: 1fr;
    }

    .repo-sidebar {
        display: none;
    }

    .mobile-category-control-group {
        display: flex !important;
        flex-direction: column;
        gap: 8px;
    }

    /* Mobile: show dropdown */
    .filter-select-group {
        display: block;
    }

    /* Skeleton single bar on mobile */
    .filter-skeleton {
        flex-direction: column;
    }

    .filter-skeleton-item {
        height: 48px;
    }

    .filter-skeleton-item.short {
        display: none;
    }

    .filter-skeleton-item:not(.short) ~ .filter-skeleton-item:not(.short) {
        display: none;
    }

    .repo-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-container {
        max-width: 100%;
    }

    .filter-controls {
        justify-content: flex-start;
    }

    .control-group {
        flex: 1;
    }
}

/* ===========================================
   Responsive — Tablet / Large Phone (≤768px)
   =========================================== */

@media (max-width: 768px) {
    .documents-section {
        padding: 80px 16px;
    }

    .repo-content-header {
        gap: 20px;
        margin-bottom: 30px;
    }

    .repo-controls {
        padding: 16px;
        gap: 16px;
    }

    #doc-search {
        padding: 14px 14px 14px 44px;
        font-size: 0.88rem;
    }

    .filter-controls {
        flex-direction: column;
        gap: 12px;
    }

    .control-group {
        width: 100%;
    }

    .date-range-group {
        min-width: 0;
    }

    .date-range-inputs {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 8px;
        border: none;
        background: transparent;
        padding: 0;
    }

    .date-range-inputs .input-wrapper {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        padding: 10px 14px;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    }

    .date-range-inputs .input-wrapper:focus-within {
        background: white;
        border-color: var(--primary-blue);
        box-shadow: 0 0 0 3px rgba(0, 49, 80, 0.08);
    }

    .date-range-inputs input[type="date"] {
        width: 100%;
        border: none;
        background: transparent;
        padding: 0;
        font-family: inherit;
        font-size: 0.82rem;
        font-weight: 700;
        color: var(--primary-blue);
        min-width: 0;
        flex: 1;
        cursor: pointer;
    }

    .range-divider {
        font-size: 0.75rem;
        font-weight: 800;
        color: #94a3b8;
        padding: 0 4px;
        text-transform: uppercase;
    }

    .select-wrapper,
    #sort-filter-wrapper {
        min-width: 0;
        width: 100%;
    }

    /* Cards: 2-column when space permits, else single */
    .document-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 16px;
    }

    .document-card {
        padding: 22px;
    }

    .document-card:hover {
        transform: none;
    }

    .doc-type-icon {
        font-size: 1.8rem;
        margin-bottom: 14px;
    }

    .doc-title {
        font-size: 1rem;
    }

    .doc-meta {
        margin-bottom: 16px;
    }

    .doc-tags {
        margin-bottom: 14px;
    }

    .repo-main-content {
        min-height: 400px;
    }
}

/* ===========================================
   Responsive — Phone (≤480px)
   =========================================== */

@media (max-width: 480px) {
    .documents-section {
        padding: 50px 12px;
    }

    .custom-dropdown-trigger {
        padding: 12px 14px;
        font-size: 0.85rem;
    }

    /* Single column cards */
    .document-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .document-card {
        padding: 18px;
    }

    .doc-title {
        font-size: 0.95rem;
        margin-bottom: 8px;
    }

    .doc-type-icon {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }

    .doc-meta {
        margin-bottom: 12px;
    }

    .doc-tags {
        margin-bottom: 10px;
        gap: 4px;
    }

    .doc-tag {
        font-size: 0.6rem;
        padding: 2px 8px;
    }

    .btn-action-primary,
    .btn-action-outline {
        padding: 10px;
        font-size: 0.7rem;
    }

    .doc-actions {
        gap: 8px;
    }

    .repo-controls {
        padding: 12px;
        gap: 12px;
    }

    #doc-search {
        padding: 12px 12px 12px 40px;
        font-size: 0.85rem;
    }

    .search-icon {
        left: 14px;
        font-size: 0.9rem;
    }

    .repo-content-header {
        gap: 16px;
        margin-bottom: 20px;
    }
}
