/* =========================================================
   VARIABLES
========================================================= */
:root {
    --primary: #4e73df;
    --accent: #10b981;

    --bg-light: #f5f6fa;
    --card-light: #ffffff;
    --text-light: #1a1a1a;
    --subtext-light: #555;
    --border-light: #e5e7eb;

    --bg-dark: #1e1f25;
    --card-dark: #2a2c33;
    --text-dark: #f5f5f5;
    --subtext-dark: #bdbdbd;
    --border-dark: #3c3f47;

    --radius: 14px;
    --shadow: 0 4px 18px rgba(0,0,0,0.08);
}

/* =========================================================
   BODY + DARK MODE
========================================================= */
html, body {
    margin: 0;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: "Inter", sans-serif;
    background: var(--bg-light);
    color: var(--text-light);
    transition: .25s;
}

body.dark-mode {
    background: var(--bg-dark);
    color: var(--text-dark);
}

/* =========================================================
   HEADER
========================================================= */
#header {
    padding: 28px 40px;
    font-weight: 600;
    background: var(--card-light);
    box-shadow: var(--shadow);
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 30px;
    position: relative;
    transition: .25s;
}
body.dark-mode #header { background: var(--card-dark); }

#title { font-size: 26px; margin: 0; color: var(--primary); }

#subtitle {
    font-size: 14px;
    margin-top: 4px;
    color: var(--subtext-light);
    transition: .25s;
}
body.dark-mode #subtitle { color: var(--subtext-dark); }

/* theme toggle */
#themeToggle {
    position: absolute;
    top: 22px;
    right: 40px;
    width: 38px;
    height: 38px;
    background: var(--card-light);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: .25s;
}
body.dark-mode #themeToggle {
    background: var(--card-dark);
    border-color: var(--border-dark);
}

/* =========================================================
   LAYOUT
========================================================= */
#layout {
    min-height: calc(100vh - 130px);
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 28px;
    padding: 0 40px 40px;
    align-items: start;
    overflow: visible;
}

/* =========================================================
   LEFT PANEL
========================================================= */
#leftPanel {
    background: var(--card-light);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    overflow-y: auto;
    transition: .25s;
}
body.dark-mode #leftPanel {
    background: var(--card-dark);
    border-color: var(--border-dark);
}

.item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: .25s;
}
body.dark-mode .item { border-color: var(--border-dark); }

.item:hover { background: rgba(0,0,0,0.05); }
body.dark-mode .item:hover { background: rgba(255,255,255,0.06); }

.item.selected { background: rgba(0,0,0,0.08); }
body.dark-mode .item.selected { background: rgba(255,255,255,0.12); }

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 12px;
}

/* test button */
#testBtn {
    margin-top: 20px;
    width: 100%;
    padding: 12px 0;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    cursor: pointer;
    transition: .25s;
}
#testBtn:hover { filter: brightness(.93); }

/* =========================================================
   RIGHT PANEL
========================================================= */
#rightPanel {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
}

.card {
    background: var(--card-light);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: .25s;
}
body.dark-mode .card {
    background: var(--card-dark);
    border-color: var(--border-dark);
}

/* =========================================================
   FILE MANAGER GRID — DESKTOP 6, TABLET 3, MOBILE 2
========================================================= */
#fmPanel {
    display: flex;
    flex-direction: column;
    height: auto;
}

#fmList {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 22px;
    overflow-y: auto;
    padding: 0 8px 24px 0;
}

/* tablet */
@media(max-width: 1024px) {
    #fmList { grid-template-columns: repeat(3, 1fr); }
}

/* mobile */
@media(max-width: 600px) {
    #fmList { grid-template-columns: repeat(2, 1fr); }
}

/* scrollbar */
#fmList::-webkit-scrollbar { width: 8px; }
#fmList::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 6px;
}
body.dark-mode #fmList::-webkit-scrollbar-thumb { background: #555; }

/* =========================================================
   SUBJECT CARD
========================================================= */
.subjectCard {
    background: var(--card-light);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 22px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: .25s;
}
body.dark-mode .subjectCard {
    background: var(--card-dark);
    border-color: var(--border-dark);
}

.subjectCard:hover { transform: translateY(-4px); }

.subjectBadge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    margin-bottom: 10px;
}

.subjectName {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

/* =========================================================
   FOLDER CARD
========================================================= */
.folderCard {
    width: 250px;
    height: 130px;
    background: var(--card-light);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: .25s;
}
body.dark-mode .folderCard {
    background: var(--card-dark);
    border-color: var(--border-dark);
}

.folderCard:hover { transform: translateY(-4px); }

.folderBadge {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    margin-bottom: 10px;
}

.folderName {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-light);
}
body.dark-mode .folderName { color: var(--text-dark); }

/* =========================================================
   THUMBNAIL CARD
========================================================= */
.thumbCard {
    width: 200px;
    height: 260px;
    display: flex;
    flex-direction: column;
    background: #2b2b2b;
    border: 1px solid #3a3a3a;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: .2s;
}
.thumbCard:hover { transform: translateY(-4px); }

.thumbImg {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.thumbLabel {
    height: 60px;
    padding: 8px 10px;
    background: #464646;
    color: #fff;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================================
   IMAGE VIEWER
========================================================= */
#imgViewer {
    position: fixed;
    inset: 0;
    background: #111;
    display: none;
    flex-direction: column;
    z-index: 99999;
}

#imgTopBar {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    height: 64px;
    background: #1c1c1c;
    border-bottom: 1px solid #333;
}

#toolbarRight {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

#imgTopBar button,
#imgTopBar a {
    background: #2e2e2e;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
}
#imgTopBar button:hover {
    background: #3c3c3c;
}

#imgViewArea {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

#bigImage {
    max-width: 100%;
    max-height: 100%;
    transition: transform .1s ease-out;
}

#imgCounter {
    position: absolute;
    top: 72px;
    left: 24px;
    font-size: 18px;
    color: white;
    opacity: .9;
    font-weight: 600;
    z-index: 20;
}

#prevFloat, #nextFloat {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(4px);
    color: white;
    font-size: 32px;
    border: none;
    cursor: pointer;
    transition: .2s;
    z-index: 15;
}
#prevFloat { left: 40px; }
#nextFloat { right: 40px; }

#prevFloat:hover, #nextFloat:hover {
    background: rgba(255,255,255,0.33);
    transform: translateY(-50%) scale(1.12);
}

/* thumbnails */
#thumbStripContainer {
    background: #1c1c1c;
    padding: 10px 0 14px;
    display: flex;
    justify-content: center;
}

#thumbStrip {
    display: flex;
    gap: 12px;
    padding: 4px 10px;
    overflow-x: auto;
    max-width: 80%;
}

.thumbMini {
    width: 120px;
    height: 90px;
    border-radius: 8px;
    object-fit: cover;
    opacity: .6;
    cursor: pointer;
    transition: .2s;
}

.thumbMini:hover,
.thumbMini.active { opacity: 1; }

.thumbMini.active {
    outline: 2px solid var(--primary);
}

/* =========================================================
   RESPONSIVE — LAYOUT COLLAPSE
========================================================= */
@media(max-width: 900px) {
    #layout { grid-template-columns: 1fr; }
}

/* =========================================================
   IMAGE VIEWER (FULLSCREEN RESTORE)
========================================================= */

#imgViewer {
    position: fixed;
    inset: 0;
    background: #111;
    display: none;
    flex-direction: column;
    z-index: 99999;
}

/* top bar */
#imgTopBar {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    height: 64px;
    background: #1c1c1c;
    border-bottom: 1px solid #333;
}

#toolbarRight {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

/* buttons */
#imgTopBar button,
#imgTopBar a {
    background: #2e2e2e;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#imgTopBar button:hover {
    background: #3c3c3c;
}

/* view area */
#imgViewArea {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

#bigImage {
    max-width: 100%;
    max-height: 100%;
    transition: transform .15s ease-out;
}

/* counter */
#imgCounter {
    position: absolute;
    top: 72px;
    left: 24px;
    font-size: 18px;
    color: white;
    opacity: .9;
    font-weight: 600;
    z-index: 20;
}

/* floating arrows */
#prevFloat, #nextFloat {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(4px);
    color: white;
    font-size: 32px;
    border: none;
    cursor: pointer;
    transition: .2s;
    z-index: 15;
}

#prevFloat { left: 40px; }
#nextFloat { right: 40px; }

#prevFloat:hover,
#nextFloat:hover {
    background: rgba(255,255,255,0.33);
    transform: translateY(-50%) scale(1.12);
}

/* thumbnails strip */
#thumbStripContainer {
    background: #1c1c1c;
    padding: 10px 0 14px;
    display: flex;
    justify-content: center;
    border-top: 1px solid #333;
}

#thumbStrip {
    display: flex;
    gap: 12px;
    padding: 4px 10px;
    overflow-x: auto;
    max-width: 80%;
}

.thumbMini {
    width: 120px;
    height: 90px;
    border-radius: 8px;
    object-fit: cover;
    opacity: .6;
    cursor: pointer;
    transition: .2s;
}

.thumbMini:hover,
.thumbMini.active {
    opacity: 1;
}

.thumbMini.active {
    outline: 2px solid var(--primary);
}

/* =========================================================
   IMPROVED CARD & BADGE VISIBILITY (LIGHT + DARK)
========================================================= */

/* LIGHT MODE – card */
.subjectCard,
.folderCard,
.thumbCard {
    background: #fafafa !important;
    border-color: #d8d8d8 !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.06) !important;
}

/* DARK MODE – card easier to see */
body.dark-mode .subjectCard,
body.dark-mode .folderCard,
body.dark-mode .thumbCard {
    background: #2d2f36 !important;     /* slightly brighter */
    border-color: #4a4d57 !important;    /* clearer border */
    box-shadow: 0 4px 14px rgba(0,0,0,0.25) !important;
}

/* BADGE IMPROVED */
.subjectBadge,
.folderBadge {
    filter: brightness(1) !important; /* normal brightness for light mode */
}

/* DARK MODE BADGE – reduce brightness (less harsh) */
body.dark-mode .subjectBadge,
body.dark-mode .folderBadge {
    filter: brightness(0.88) !important;
}

/* title inside card darker for readability */
.subjectName,
.folderName {
    color: #111 !important;
}

body.dark-mode .subjectName,
body.dark-mode .folderName {
    color: #f1f1f1 !important;
}

#answerOverlay {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 14px 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    color: white;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
    z-index: 25;
}