:root {
    --primary-color: #4a90e2;
    --secondary-color: #50e3c2;
    --background-color: #f4f7f6;
    --panel-background: #ffffff;
    --text-color: #4a4a4a;
    --light-text-color: #9b9b9b;
    --border-color: #e6e6e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* Login Page Styles */
.container {
    background-color: var(--panel-background);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 15px var(--shadow-color);
    width: 100%;
    max-width: 400px;
}

.container form {
    display: flex;
    flex-direction: column;
}

.container h2 {
    text-align: center;
    margin-bottom: 25px;
    font-weight: 600;
    color: var(--primary-color);
}

.container label {
    margin-bottom: 8px;
    font-weight: 500;
}

.container input {
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
}

.container button {
    padding: 12px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.container button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--shadow-color);
}

/* Main App Styles */
.main-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    background-color: var(--panel-background);
}

.left-panel {
    width: 350px;
    padding: 20px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background-color: #fbfbfb;
}

.left-panel h2 {
    text-align: center;
    margin-bottom: 20px;
    font-weight: 600;
}

.right-panel {
    flex-grow: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    /* The container will manage its own overflow */
}

/* Tabs */
.tab {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.tab button {
    background-color: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 14px 16px;
    transition: color 0.3s, border-bottom 0.3s;
    flex-grow: 1;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    color: var(--light-text-color);
    border-bottom: 3px solid transparent;
}

.tab button:hover {
    color: var(--primary-color);
}

.tab button.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}

.tabcontent {
    display: none;
    padding: 15px 5px;
    flex-grow: 1;
    overflow-y: auto;
}

.tabcontent h3 {
    margin-bottom: 15px;
    font-weight: 500;
}

/* Document Lists */
#unsigned-documents, #signed-documents {
    list-style: none;
}

#unsigned-documents li, #signed-documents li {
    margin-bottom: 10px;
}

#unsigned-documents a, #signed-documents a {
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    padding: 10px;
    border-radius: 5px;
    transition: background-color 0.2s, color 0.2s;
}

.doc-name {
    font-weight: 500;
    word-break: break-all;
}

.doc-date {
    font-size: 0.8rem;
    color: var(--light-text-color);
    margin-top: 4px;
}

.no-documents {
    color: var(--light-text-color);
    text-align: center;
    padding: 20px;
}

#unsigned-documents a:hover, #signed-documents a:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Upload Form */
form {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

input[type="file"] {
    margin-bottom: 10px;
}

input[type="submit"] {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    transition: background-color 0.2s;
}

input[type="submit"]:hover {
    background: #3a7ac2;
}

/* PDF Viewer */
#canvas-container {
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
    margin-bottom: 15px;
    flex-grow: 1; /* Allow the container to fill available vertical space */
    flex-shrink: 1;
    min-height: 0; /* Prevents flexbox overflow issues */
    overflow: auto; /* Add scrollbars if the zoomed content is larger than the container */
    padding: 10px;
    background-color: #f0f0f0;
}

#canvas-container canvas {
    max-width: 100%;
    height: auto;
}

#signature-canvas {
    cursor: crosshair;
}

/* Controls */
#navigation-controls, #signature-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
    flex-shrink: 0; /* Prevent controls from shrinking */
    flex-wrap: wrap; /* Allow buttons to wrap on small screens */
}

#navigation-controls span {
    font-weight: 500;
}

#zoom-level {
    width: 50px;
    text-align: center;
}

#navigation-controls button, #signature-controls button {
    padding: 8px 16px;
    border: 1px solid var(--primary-color);
    background-color: var(--panel-background);
    color: var(--primary-color);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

#navigation-controls button:hover, #signature-controls button:hover {
    background-color: var(--primary-color);
    color: white;
}

#save-document-button {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

#save-document-button:hover {
    background-color: #40c3a2;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
    }

    .main-container {
        flex-direction: column;
        height: auto;
    }

    .left-panel {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .right-panel {
        width: 100%;
        padding: 10px;
    }

    .container {
        padding: 20px;
    }
}
