:root {
    --bg: #0b1220;
    --card: #111a2b;
    --text: #e6e9ef;
    --acc: #2dd4bf;
    --accent-hover: #22bca9;
    --nav-bg: #0a1020;
    --btn-bg: #22314f;
    --btn-hover: #2b7cff;
    --nav-height: 64px;
}

/* ---------------- RESET ---------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    font: 16px/1.6 "Segoe UI", Roboto, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    overflow-y: auto; 
    /* no window scroll – tools manage their own scroll */
}

/* ---------------- NAVBAR ---------------- */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--nav-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    border-bottom: 1px solid #1f2a44;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.brand {
    font-weight: 700;
    font-size: 1.3rem;
    color: #fff;
    text-decoration: none;
    letter-spacing: 0.5px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-right .welcome {
    color: #bbb;
    font-size: 0.95rem;
}

/* ---------------- BUTTONS ---------------- */
.btn {
    background: var(--btn-bg);
    border: none;
    color: #fff;
    padding: 9px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    min-width: 100px;
    transition: background 0.25s ease, transform 0.15s ease;
    cursor: pointer;
}

.btn:hover {
    background: var(--btn-hover);
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--acc);
    color: #000;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

/* ---------------- MAIN CONTAINER ---------------- */
main.container {
    max-width: 1200px;
    margin: calc(var(--nav-height) + 20px) auto 0;
    padding: 0 40px 60px;
    background: var(--bg);

    /* Full-height workspace below navbar */
    height: calc(100vh - var(--nav-height) - 20px);
    box-sizing: border-box;

    /* let children (like .editor-shell) manage scrolling */
    overflow: hidden;
}

/* ---------------- HEADINGS ---------------- */
h1,
h2,
h3 {
    color: #fff;
    font-weight: 700;
    margin-bottom: 20px;
}

/* ---------------- DASHBOARD CARDS ---------------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 10px;
}

.card {
    background: var(--card);
    border: 1px solid #22314f;
    border-radius: 12px;
    padding: 20px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s ease;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.25);
}

.card:hover {
    transform: translateY(-3px);
    border-color: var(--acc);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.card-title {
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 1.05rem;
}

/* ---------------- TABLE (My Files) ---------------- */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: #121821;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    margin-top: 20px;
}

th,
td {
    padding: 14px 18px;
    text-align: left;
    font-size: 0.95rem;
}

thead {
    background-color: #1f2833;
}

tbody tr {
    border-top: 1px solid #2a333e;
}

tbody tr:hover {
    background-color: #1b2432;
}

/* ---------------- FORMS ---------------- */
label {
    display: block;
    margin: 10px 0 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
.input {
    width: 100%;
    padding: 10px;
    border: 1px solid #22314f;
    border-radius: 8px;
    background: #0c1426;
    color: #fff;
}

/* Alerts */
.alert {
    background: #3b1d1d;
    color: #ffd6d6;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 20px;
        height: auto;
    }

    .nav-right {
        margin-top: 8px;
        width: 100%;
        justify-content: flex-end;
    }

    main.container {
        padding: 20px;
        margin-top: calc(var(--nav-height) + 20px);
        height: calc(100vh - var(--nav-height) - 40px);
    }
}

/* =====================================================
   =============== PDF EDITOR TOOL ======================
   ===================================================== */

/* Main two-column layout */
.editor-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;

    /* full height working area under navbar & heading */
    height: calc(100vh - var(--nav-height) - 80px);
}

/* Sidebar */
.editor-sidebar {
    background: #0f1625;
    border: 1px solid #22314f;
    border-radius: 10px;
    padding: 14px;
    overflow-y: auto;
}

/* Right side: toolbar + pages */
.editor-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Toolbar at top of editor */
.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(16, 24, 39, 0.95);
    border: 1px solid #22314f;
    border-radius: 10px;
    padding: 10px 14px;
    flex-shrink: 0;
    backdrop-filter: blur(6px);
    transition: background 0.3s ease;
}

.editor-toolbar.scrolled {
    background: rgba(16, 24, 39, 0.85);
}

.muted {
    color: #9aa6b2;
    font-size: 0.9rem;
}

/* Scrollable area for PDF pages ONLY */
.pages-wrap {
    flex: 1;
    margin-top: 10px;
    border: 1px solid #22314f;
    border-radius: 10px;
    background: #0f1625;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    scrollbar-gutter: stable;
}

/* Center each PDF page */
.pages-wrap .page {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

/* The PDF canvas itself */
.pages-wrap canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Editable text boxes */
.textbox {
    position: absolute;
    font-family: Arial, Helvetica, sans-serif !important;
    min-width: 60px;
    min-height: 28px;
    padding: 0px !important;
    outline: 1px dashed #2b7cff;
    background: transparent;
    cursor: move;
    white-space: pre-wrap;
    user-select: text;
    outline: none;
}

.textbox.editing .tb-resize {
    display: block !important;
}

/* Selected but not editing */
.textbox.active {
    outline: 1px dashed #2b7cff;
}

/* Editing mode (double-click or newly created) */
.textbox.editing {
    outline: 2px solid #2b7cff;
    cursor: text;
}

/* Resize handle in bottom-right corner */

.tb-resize {
    position: absolute;
    width: 10px;
    height: 10px;
    right: -3px;
    bottom: -3px;
    background: #2b7cff;
    border-radius: 2px;
    cursor: nwse-resize;
    z-index: 9999;
}

/* Custom scrollbar INSIDE the pages area */
.pages-wrap::-webkit-scrollbar {
    width: 8px;
}

.pages-wrap::-webkit-scrollbar-track {
    background: #0f1625;
}

.pages-wrap::-webkit-scrollbar-thumb {
    background-color: #2b7cff;
    border-radius: 4px;
}

.textbox .tb-resize {
    display: block !important;
    opacity: 1 !important;
}

.textbox.editing .tb-resize {
    display: block !important;
}

/* additional */
/* ----- SIDEBAR FIX ----- */

.editor-sidebar .tool-section {
    margin-bottom: 20px;
}

.editor-sidebar .tool-section .btn {
    width: 100%;
    margin-bottom: 10px;
}

.editor-sidebar .tool-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.editor-sidebar select,
.editor-sidebar input[type="color"] {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 10px;
    background: #0c1426;
    border: 1px solid #22314f;
}

.editor-sidebar #btn-download {
    margin-top: 10px;
    width: 100%;
}

.editor-sidebar a.btn {
    width: 100%;
    text-align: center;
}

.hint {
    font-size: 0.85rem;
    color: #aaa;
    line-height: 1.4;
    margin-top: 10px;
}



/* Match sidebar scrollbar exactly to PDF scrollbar */
.editor-sidebar::-webkit-scrollbar {
    width: 8px;
}

.editor-sidebar::-webkit-scrollbar-track {
    background: #0f1625;
}

.editor-sidebar::-webkit-scrollbar-thumb {
    background-color: #2b7cff;
    border-radius: 4px;
}

/* Remove sidebar scroll arrows */
.editor-sidebar::-webkit-scrollbar-button {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}
