/**
 * AKOM Docs Frontend CSS
 * Modern Design System
 */

:root {
    --akom-bg: #FFFFFF;
    --akom-card-bg: #FAFAFA;
    --akom-primary: #82C8E5;
    --akom-secondary: #90D5FF;
    --akom-btn: #E8B18C;
    --akom-btn-hover: #D9986A;
    --akom-text: #2D3748;
    --akom-text-muted: #718096;
    --akom-border-radius: 18px;
    --akom-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    --akom-shadow-hover: 0 18px 40px rgba(130, 200, 229, 0.2);
    --akom-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.akom-dark-mode {
    --akom-bg: #1A202C;
    --akom-card-bg: #2D3748;
    --akom-text: #F7FAFC;
    --akom-text-muted: #A0AEC0;
    --akom-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.akom-docs-container {
    background: var(--akom-bg);
    color: var(--akom-text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 20px 0;
}

/* Toolbar & Filters Grid */
.akom-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #FFFFFF, #FAFAFA);
    padding: 20px 24px;
    border-radius: var(--akom-border-radius);
    border: 1.5px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    margin-bottom: 30px;
}

.akom-search-box {
    position: relative;
    flex: 1 1 260px;
    min-width: 240px;
    display: flex;
    align-items: center;
}

.akom-search-icon {
    position: absolute;
    left: 16px;
    pointer-events: none;
    z-index: 2;
    transition: transform 0.2s ease;
}

.akom-search-input {
    width: 100% !important;
    height: 46px !important;
    padding: 0 16px 0 46px !important;
    border: 1.5px solid #E2E8F0 !important;
    border-radius: 14px !important;
    background: #FFFFFF !important;
    color: var(--akom-text) !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    outline: none !important;
    box-shadow: none !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.akom-search-input:focus {
    border-color: var(--akom-primary) !important;
    box-shadow: 0 0 0 4px rgba(130, 200, 229, 0.2) !important;
}

.akom-search-box:focus-within .akom-search-icon {
    transform: scale(1.1);
}

.akom-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    flex: 2 1 auto;
}

.akom-filters select {
    height: 46px !important;
    padding: 0 38px 0 16px !important;
    border: 1.5px solid #E2E8F0 !important;
    border-radius: 14px !important;
    background-color: #FFFFFF !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234A5568' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    background-size: 16px !important;
    color: var(--akom-text) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    outline: none !important;
    cursor: pointer !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    box-shadow: none !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    flex: 1 1 160px;
    min-width: 140px;
}

.akom-filters select:hover {
    border-color: var(--akom-secondary) !important;
    transform: translateY(-1px);
}

.akom-filters select:focus {
    border-color: var(--akom-primary) !important;
    box-shadow: 0 0 0 4px rgba(130, 200, 229, 0.2) !important;
}

/* View Switcher */
.akom-view-switcher {
    display: inline-flex;
    background: #F1F5F9;
    padding: 4px;
    border-radius: 14px;
    border: 1px solid #E2E8F0;
    gap: 2px;
}

.akom-view-btn {
    border: none !important;
    background: transparent !important;
    padding: 8px 14px !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--akom-text-muted) !important;
    transition: all 0.2s ease !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--akom-text-muted);
    transition: var(--akom-transition);
}

.akom-view-btn.active {
    background: #FFFFFF;
    color: var(--akom-text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Cards Grid Layout */
.akom-view-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.akom-cols-2 { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.akom-cols-4 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.akom-doc-card {
    background: var(--akom-card-bg);
    border-radius: var(--akom-border-radius);
    box-shadow: var(--akom-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: var(--akom-transition);
}

.akom-doc-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--akom-shadow-hover);
}

.akom-doc-card.is-featured {
    border: 2px solid var(--akom-primary);
}

.akom-card-media {
    height: 140px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.akom-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.akom-card-icon-wrap .dashicons {
    font-size: 56px;
    width: 56px;
    height: 56px;
}

.akom-badge-type {
    position: absolute;
    bottom: 12px;
    right: 12px;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    text-transform: uppercase;
}

.akom-badge-featured {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #D69E2E;
    color: #FFF;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.akom-card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.akom-card-category {
    font-size: 12px;
    color: var(--akom-primary);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.akom-card-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 10px;
    line-height: 1.3;
}

.akom-card-title a {
    color: var(--akom-text);
    text-decoration: none;
}

.akom-card-title a:hover {
    color: var(--akom-primary);
}

.akom-card-excerpt {
    font-size: 13px;
    color: var(--akom-text-muted);
    margin: 0 0 15px;
    line-height: 1.5;
    flex: 1;
}

.akom-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--akom-text-muted);
    padding-top: 12px;
    border-top: 1px solid #EDF2F7;
}

.akom-card-footer {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    background: rgba(0,0,0,0.02);
}

.akom-btn-preview, .akom-btn-download {
    flex: 1;
    text-align: center;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--akom-transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.akom-btn-preview {
    background: #EDF2F7;
    color: var(--akom-text);
    border: none;
}

.akom-btn-preview:hover {
    background: #E2E8F0;
}

.akom-btn-download {
    background: var(--akom-btn);
    color: #2D3748;
    border: none;
}

.akom-btn-download:hover {
    background: var(--akom-btn-hover);
    color: #FFFFFF;
}

/* List Layout */
.akom-list-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.akom-list-item {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--akom-card-bg);
    padding: 16px 24px;
    border-radius: var(--akom-border-radius);
    box-shadow: var(--akom-shadow);
    transition: var(--akom-transition);
}

.akom-list-item:hover {
    transform: translateX(4px);
    box-shadow: var(--akom-shadow-hover);
}

.akom-list-icon .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
}

.akom-list-info {
    flex: 1;
}

.akom-list-title {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
}

.akom-list-title a {
    color: var(--akom-text);
    text-decoration: none;
}

.akom-list-desc {
    margin: 0;
    font-size: 13px;
    color: var(--akom-text-muted);
}

.akom-list-meta {
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 13px;
    color: var(--akom-text-muted);
}

.akom-meta-tag {
    background: var(--akom-primary);
    color: #2D3748;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
}

/* Compact Layout */
.akom-compact-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.akom-compact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--akom-card-bg);
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
}

.akom-compact-title {
    flex: 1;
    color: var(--akom-text);
    text-decoration: none;
    font-weight: 600;
}

.akom-compact-badge {
    background: #E2E8F0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.akom-compact-btn {
    color: var(--akom-btn-hover);
    text-decoration: none;
}

/* ============================================
   MODAL PREMIUM – Fixed Header, Scroll Body, Fixed Footer
   ============================================ */

/* CSS Variables for runtime customisation */
:root {
    --akom-modal-overlay-bg:   rgba(15, 23, 42, 0.72);
    --akom-modal-bg:           #FFFFFF;
    --akom-modal-header-bg:    var(--akom-primary, #82C8E5);
    --akom-modal-header-text:  #1A202C;
    --akom-modal-body-bg:      #F8FAFC;
    --akom-modal-footer-bg:    #FFFFFF;
    --akom-modal-radius:       22px;
    --akom-modal-shadow:       0 32px 80px rgba(15,23,42,0.28), 0 8px 24px rgba(0,0,0,0.12);
}

/* Overlay */
.akom-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--akom-modal-overlay-bg);
    backdrop-filter: blur(8px) saturate(180%);
    -webkit-backdrop-filter: blur(8px) saturate(180%);
    z-index: 99998;
    animation: akomFadeIn .2s ease;
}

/* Dialog Shell – true flex column */
.akom-modal-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: 92%;
    max-width: 860px;
    max-height: 88vh;
    background: var(--akom-modal-bg);
    border-radius: var(--akom-modal-radius);
    box-shadow: var(--akom-modal-shadow);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: akomModalIn .28s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

@keyframes akomFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes akomModalIn {
    from { opacity: 0; transform: translate(-50%,-48%) scale(0.92); }
    to   { opacity: 1; transform: translate(-50%,-50%) scale(1);    }
}

/* Fixed Header */
.akom-modal-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 26px;
    background: var(--akom-modal-header-bg);
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.akom-modal-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.akom-modal-header-icon {
    font-size: 26px;
    width: 26px;
    height: 26px;
    color: var(--akom-modal-header-text);
    flex-shrink: 0;
}

.akom-modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--akom-modal-header-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.akom-modal-close {
    flex-shrink: 0;
    background: rgba(0,0,0,0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--akom-modal-header-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s, transform .18s;
}

.akom-modal-close:hover {
    background: rgba(0,0,0,0.22);
    transform: rotate(90deg);
}

/* Scrollable Body */
.akom-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    background: var(--akom-modal-body-bg);
    padding: 0;
    position: relative;
    min-height: 280px;
}

/* Loading spinner inside body */
.akom-modal-body.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--akom-modal-body-bg);
}

.akom-modal-body-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: 48px;
    height: 48px;
    border: 4px solid rgba(130,200,229,0.25);
    border-top-color: var(--akom-primary);
    border-radius: 50%;
    animation: akomSpin 0.7s linear infinite;
}

/* PDF iframe */
.akom-pdf-iframe-container {
    width: 100%;
    height: 480px;
    background: #1A202C;
    overflow: hidden;
}

.akom-pdf-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Fallback preview (non-PDF) */
.akom-preview-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 30px;
    text-align: center;
    gap: 14px;
    min-height: 280px;
    background: var(--akom-modal-body-bg);
}

.akom-preview-fallback h4 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--akom-text);
}

.akom-preview-fallback p {
    margin: 0;
    font-size: 14px;
    color: var(--akom-text-muted);
    max-width: 420px;
}

/* Fixed Footer */
.akom-modal-footer {
    flex-shrink: 0;
    background: var(--akom-modal-footer-bg);
    border-top: 1px solid #EDF2F7;
}

/* Footer Content Layout */
.akom-preview-footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 22px;
    flex-wrap: wrap;
}

/* Meta Pills */
.akom-preview-meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.akom-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #EDF2F7;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--akom-text);
    font-weight: 500;
    line-height: 1;
}

.akom-meta-pill .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: var(--akom-primary);
}

.akom-meta-pill strong {
    font-weight: 700;
    color: var(--akom-text-muted);
}

/* QR thumb */
.akom-qr-thumb {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    border: 2px solid #EDF2F7;
    flex-shrink: 0;
}

/* Footer Actions */
.akom-preview-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* ============================================
   ASYNC DOWNLOAD BUTTON – loading state
   ============================================ */

.akom-btn-download,
.akom-async-download-btn {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: background .22s, color .22s, transform .18s, box-shadow .22s;
}

.akom-btn-download:active,
.akom-async-download-btn:active {
    transform: scale(0.97);
}

/* Loading state – spinner replaces icon */
.akom-btn-download.is-loading,
.akom-async-download-btn.is-loading {
    pointer-events: none;
    color: transparent !important;
}

.akom-btn-download.is-loading::after,
.akom-async-download-btn.is-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin: -9px 0 0 -9px;
    border: 2.5px solid rgba(255,255,255,0.4);
    border-top-color: #2D3748;
    border-radius: 50%;
    animation: akomSpin 0.65s linear infinite;
}

@keyframes akomSpin {
    to { transform: rotate(360deg); }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

#akom-toast-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.akom-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: #1A202C;
    color: #FFFFFF;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 28px rgba(0,0,0,0.22);
    pointer-events: auto;
    animation: akomToastIn .3s cubic-bezier(0.34,1.56,0.64,1);
    max-width: 340px;
}

.akom-toast.is-success { border-left: 4px solid #68D391; }
.akom-toast.is-error   { border-left: 4px solid #FC8181; }
.akom-toast.is-info    { border-left: 4px solid var(--akom-primary); }

.akom-toast .akom-toast-icon {
    font-size: 20px;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.akom-toast.is-success .akom-toast-icon { color: #68D391; }
.akom-toast.is-error   .akom-toast-icon { color: #FC8181; }
.akom-toast.is-info    .akom-toast-icon { color: var(--akom-primary); }

@keyframes akomToastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes akomToastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .akom-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .akom-filters {
        flex-direction: column;
    }

    .akom-list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .akom-modal-dialog {
        width: 98%;
        max-height: 95vh;
        border-radius: 16px;
    }

    .akom-pdf-iframe-container {
        height: 320px;
    }

    .akom-preview-footer-content {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 16px;
    }

    .akom-preview-actions {
        width: 100%;
        justify-content: space-between;
    }

    #akom-toast-container {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }

    .akom-toast {
        max-width: 100%;
    }
}
