/* **************************************************
   PDF MARKUP TOOL STYLES

   This stylesheet is grouped by app area so the UI
   can grow without becoming hard to navigate.
   ************************************************** */

/* **************************************************
   RESET AND BASE PAGE
   ************************************************** */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;

    font-family: Arial, Helvetica, sans-serif;
    background: #1e1e1e;
    color: #ffffff;
}

/* **************************************************
   SHARED CONTROLS
   ************************************************** */

button {
    cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.active {
    background: #4a90e2;
}

/* **************************************************
   TOP TOOLBAR
   ************************************************** */

.toolbar {
    min-height: 60px;

    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;

    padding: 10px 20px;

    background: #252526;
    border-bottom: 1px solid #333;
}

.toolbar button {
    padding: 8px 16px;
}

.toolbar #fileMenuBtn {
    font-weight: bold;
}

.document-title-input {
    width: 180px;
    padding: 8px 10px;

    color: #ffffff;
    background: #1e1e1e;
    border: 1px solid #444;
}

.toolbar-title {
    font-weight: bold;
}

/* **************************************************
   MAIN WORKSPACE
   ************************************************** */

.viewer-container {
    flex: 1;
    min-height: 0;

    display: flex;
    gap: 15px;

    padding: 20px;

    overflow: hidden;
}

/* **************************************************
   LEFT TOOL PANEL
   ************************************************** */

.tool-panel {
    width: 170px;
    flex: 0 0 170px;
    min-height: 0;

    display: flex;
    flex-direction: column;
    gap: 10px;

    padding: 10px;

    background: #252526;
    border: 1px solid #333;

    overflow-x: hidden;
    overflow-y: auto;
}

.tool-btn {
    padding: 8px;
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tool-menu-btn::after {
    content: " ▾";
}

.tool-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;

    padding: 6px;

    background: #1e1e1e;
    border: 1px solid #3a3a3a;
}

.tool-menu[hidden] {
    display: none;
}

.symbol-library {
    max-height: 170px;
    overflow: auto;
}

.symbol-btn {
    text-align: left;
}

.tool-options {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-options label {
    display: flex;
    align-items: center;
    gap: 8px;

    font-size: 0.8rem;
}

.toolbar-options {
    padding: 0 8px;
}

.properties-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;

    margin-top: 10px;
    padding-top: 12px;

    border-top: 1px solid #3a3a3a;
}

.properties-toggle {
    width: 100%;
    padding: 8px;

    text-align: left;
    font-weight: bold;
}

.properties-toggle::after {
    content: " ▾";
}

.properties-panel.collapsed .properties-toggle::after {
    content: " ▸";
}

.properties-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.properties-panel.collapsed .properties-body {
    display: none;
}

.properties-body label {
    display: flex;
    flex-direction: column;
    gap: 5px;

    font-size: 0.8rem;
}

.properties-body input[type="color"] {
    width: 100%;
    height: 34px;
}

.properties-body input[type="number"],
.properties-body input[type="text"] {
    width: 100%;
    padding: 5px;
}

.properties-body textarea {
    width: 100%;
    min-height: 80px;
    padding: 6px;

    resize: vertical;
    font-family: Arial, Helvetica, sans-serif;
}

.rotation-control {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
}

.icon-action-btn {
    min-width: 38px;
    padding: 5px 8px;
}

/* **************************************************
   PDF VIEWER

   The viewer scrolls.
   The canvas container matches the rendered PDF size.
   The PDF canvas and annotation canvas are stacked.
   ************************************************** */

#viewer {
    flex: 1;
    min-width: 0;

    border: 2px dashed #555;
    background: #2d2d2d;

    overflow: auto;
}

#canvasContainer {
    position: relative;
    display: block;

    width: 0;
    height: 0;
}

#pdfCanvas,
#annotationCanvas {
    position: absolute;
    top: 0;
    left: 0;
}

#pdfCanvas {
    background: #ffffff;
}

#annotationCanvas {
    touch-action: none;
    user-select: none;
}

/* **************************************************
   STATUS BAR
   ************************************************** */

.status-bar {
    height: 30px;

    display: flex;
    align-items: center;

    padding: 0 15px;

    background: #252526;
    border-top: 1px solid #333;

    font-size: 0.85rem;
}

/* **************************************************
   MODALS
   ************************************************** */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(0, 0, 0, 0.55);
}

.modal-backdrop[hidden] {
    display: none;
}

.file-modal {
    width: min(360px, 100%);

    padding: 16px;

    background: #252526;
    border: 1px solid #444;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    margin-bottom: 14px;
}

.modal-header h2 {
    font-size: 1rem;
}

.modal-close-btn {
    width: 36px;
    height: 36px;
    padding: 0;

    font-size: 1.2rem;
}

.file-actions {
    display: grid;
    gap: 8px;
}

.file-actions button {
    padding: 10px 12px;
    text-align: left;
}

/* **************************************************
   TABLET / SMALL SCREEN LAYOUT
   ************************************************** */

@media (max-width: 900px) {

    .toolbar {
        gap: 8px;
        padding: 8px;
    }

    .toolbar button {
        min-height: 40px;
        padding: 8px 12px;
    }

    .document-title-input {
        width: 160px;
        min-height: 40px;
    }

    .viewer-container {
        flex-direction: column;
        gap: 10px;

        padding: 10px;
    }

    .tool-panel {
        width: 100%;
        flex: 0 0 auto;
        max-height: 42vh;

        display: grid;
        grid-template-columns: repeat(5, minmax(90px, 1fr));
        align-items: start;
    }

    .tool-btn {
        min-height: 44px;
    }

    .tool-group {
        min-width: 0;
    }

    .tool-menu {
        grid-column: auto;
    }

    .properties-panel {
        grid-column: 1 / -1;
    }

    .properties-body {
        display: grid;
        grid-template-columns: repeat(4, minmax(120px, 1fr));
        gap: 10px;

        max-height: 190px;
        overflow: auto;
    }
}

@media (max-width: 560px) {

    .tool-panel,
    .properties-body {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .toolbar-title {
        width: 100%;
    }
}
