/* DASHBOARD VIEW KHUSUS KITABUNA */
:root {
    --bg-color: #f4f0ea;
    --surface: #ffffff;
    --primary: #ffe227;
    --primary-hover: #ffc300;
    --accent: #ff499e;
    --text-main: #111111;
    --text-muted: #444444;
    --border-color: #000000;
}

#kitabuna-wrapper {
    background: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: calc(100vh - 80px); /* Adjust based on Santri header */
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

#dashboard-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0 20px 20px 20px;
    overflow-y: auto;
}

.dash-header { margin-bottom: 20px; padding-top: 20px; }
.dash-header h1 {
    font-size: 32px; font-weight: 900; margin: 0;
    color: #111; letter-spacing: -1px;
    text-shadow: 2px 2px 0px var(--primary);
}
.dash-header .subtitle { 
    color: var(--text-muted); 
    font-size: clamp(10px, 3.5vw, 15px); 
    font-weight: 700; 
    margin-top: 4px; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

/* Stats */
.dash-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.dash-stat-card {
    min-width: 0;
    background: var(--surface);
    border: 3px solid var(--border-color); border-radius: 8px;
    padding: 20px; text-align: center; position: relative; overflow: hidden;
    box-shadow: 5px 5px 0px #000; transition: transform 0.1s;
}
.dash-stat-card:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0px #000; }
.dash-stat-num {
    font-size: 40px; font-weight: 900; color: #111; line-height: 1; margin-bottom: 8px;
}
.dash-stat-label { font-size: 14px; color: var(--text-muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }

/* Toolbar */
.dash-toolbar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
    background: transparent; padding: 0; border: none;
    box-shadow: none;
}

.dash-tabs { display: inline-flex; gap: 8px; overflow-x: auto; }
.dash-tab {
    background: #fff; border: 3px solid #000; color: #111; padding: 8px 20px;
    border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 800; transition: all 0.1s ease; white-space: nowrap;
    box-shadow: 3px 3px 0px #000;
}
.dash-tab.active { background: #111; color: #fff; box-shadow: 1px 1px 0px #000; transform: translate(2px, 2px); }
.dash-tab:hover:not(.active) { background: #fdfbf7; transform: translate(-1px, -1px); box-shadow: 4px 4px 0px #000; }
.dash-tab:active { box-shadow: 1px 1px 0px #000; transform: translate(2px, 2px); }

.dash-search {
    padding: 10px 16px !important; background: #fff !important; border: 3px solid var(--border-color) !important;
    border-radius: 6px !important; color: #111 !important; font-size: 14px !important; width: 250px; outline: none !important; transition: all 0.1s;
    font-weight: 700; box-shadow: 3px 3px 0px #000; box-sizing: border-box;
}
.dash-search:focus { box-shadow: 1px 1px 0px #000; transform: translate(2px, 2px); }
.neo-select {
    appearance: none; -webkit-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 140 140" xmlns="http://www.w3.org/2000/svg"><polygon points="70,100 10,40 130,40" fill="%23111"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 35px !important;
    box-sizing: border-box;
}

.arab-input { font-family: 'Amiri', serif !important; text-align: right; direction: rtl; font-size: 1.2rem !important; font-weight: bold; }

.btn-action {
    background: var(--primary); color: #111; border: 3px solid #000; padding: 10px 20px; border-radius: 6px;
    font-weight: 900; cursor: pointer; transition: all 0.1s; white-space: nowrap; box-shadow: 3px 3px 0px #000; text-transform: uppercase; box-sizing: border-box;
}
.btn-action:hover { background: var(--primary-hover); transform: translate(-1px, -1px); box-shadow: 4px 4px 0px #000; }
.btn-action:active { box-shadow: 1px 1px 0px #000; transform: translate(2px, 2px); }

/* Tables */
.dash-content { display: none; flex: 1; flex-direction: column; }
.dash-content.active { display: flex; }

.dash-badge-cat {
    display: inline-block; background: #a7c957; color: #111;
    padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 900; border: 2px solid #000;
    box-shadow: 2px 2px 0px #000; margin-bottom: 4px;
}
.dash-badge-info {
    display: inline-block; background: #4ade80; color: #111;
    padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 900; border: 2px solid #000;
    margin-top: 5px; box-shadow: 2px 2px 0px #000;
}

.dash-btn-read {
    background: var(--accent); color: white; border: 3px solid #000; padding: 8px 16px; box-shadow: 3px 3px 0px #000;
    border-radius: 6px; font-size: 13px; font-weight: 900; cursor: pointer; transition: all 0.1s; white-space: nowrap; text-transform: uppercase;
}
.dash-btn-read:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0px #000; }
.dash-btn-read:active { transform: translate(2px,2px); box-shadow: 1px 1px 0px #000; }

.loader {
    width: 30px; height: 30px; border: 4px solid #000; border-top-color: var(--primary);
    border-radius: 50%; animation: spin 1s linear infinite; margin: 20px auto;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Grid Cards */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding-bottom: 20px;
    direction: rtl;
}
.dash-grid-card {
    direction: ltr;
    background: #fff;
    border: 3px solid #000;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 5px 5px 0px #000;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.1s;
}
.dash-grid-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 7px 7px 0px #000;
}
.dash-grid.grid-cols-1 { grid-template-columns: 1fr; }
.dash-grid.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.dash-grid.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.dash-grid.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Reader Modal Sub-toolbar overrides for Kitabuna Reader */
.reader-sub-toolbar {
    background: #f4f0ea; padding: 10px 25px; border-bottom: 3px solid #000; z-index:9;
}

@media (max-width: 768px) {
    .dash-header {
        position: relative;
        background: var(--bg-color);
        padding-bottom: 10px;
        margin-top: 0;
    }
    .dash-grid, .dash-grid[class*="grid-cols-"] {
        grid-template-columns: 1fr !important;
    }
    .dash-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .dash-stat-card {
        min-width: 0;
        padding: 15px 10px;
    }
    .dash-stat-num {
        font-size: 24px;
    }
    .dash-stat-label {
        font-size: 11px;
    }
    #globalControls {
        justify-content: space-between !important;
    }
    #authorSortSelect {
        flex: 1;
        min-width: 0;
    }
    #gridColsSelect {
        display: none !important;
    }
    .dash-tabs {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 3px solid #000;
        padding: 10px;
        z-index: 100;
        overflow-x: auto;
        display: flex;
        justify-content: space-between;
        gap: 5px;
        box-shadow: 0 -4px 0px rgba(0,0,0,0.1);
    }
    .dash-tab {
        flex: 1;
        text-align: center;
        padding: 10px 5px;
        font-size: 12px;
        white-space: normal;
        line-height: 1.2;
    }
    #dashboard-view {
        padding-bottom: 120px;
    }
    .dash-toolbar {
        justify-content: center;
    }
}
.arab-highlight { background-color: var(--accent); color: #fff; padding: 0 4px; border-radius: 4px; border: 2px solid #000; font-weight: bold; }