/* ========================================
   DocViewer - Estilos Globais
   ======================================== */

:root {
    --primary-color: #3B8BD4;
    --secondary-color: #6c757d;
    --danger-color: #dc3545;
    --success-color: #1D9E75;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --header-height: 60px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* ========================================
   Landing Page
   ======================================== */

.landing-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.landing-container header h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--secondary-color);
    margin-bottom: 3rem;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    max-width: 900px;
    margin-bottom: 3rem;
}

.feature {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.feature-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.cta-section .btn {
    padding: 1rem 3rem;
    font-size: 1.1rem;
}

footer {
    margin-top: auto;
    padding-top: 2rem;
    color: var(--secondary-color);
}

/* ========================================
   Login Page
   ======================================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-box {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-box h2 {
    text-align: center;
    color: var(--secondary-color);
    margin-bottom: 2rem;
    font-size: 1.2rem;
}

.login-hint {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2a7bc4;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ========================================
   Forms
   ======================================== */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-inline {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.form-inline input {
    flex: 1;
    min-width: 120px;
}

/* ========================================
   Alerts
   ======================================== */

.alert {
    padding: 0.8rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ========================================
   App Container & Header
   ======================================== */

.app-container {
    min-height: 100vh;
}

.app-header {
    background: var(--card-bg);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    color: var(--secondary-color);
}

/* ========================================
   Painel - Grid de Documentos
   ======================================== */

.painel-main {
    padding: 2rem;
}

.docs-section {
    max-width: 1400px;
    margin: 0 auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.doc-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.doc-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.doc-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.doc-desc {
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    min-height: 2.4em;
}

.doc-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.tag {
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    color: white;
}

.doc-actions {
    display: flex;
    gap: 0.5rem;
}

/* ========================================
   Tags Checkboxes
   ======================================== */

.tags-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-checkbox {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    background: var(--bg-color);
    border-radius: 4px;
    cursor: pointer;
}

.tag-checkbox input {
    cursor: pointer;
}

/* ========================================
   Tags List (Modal)
   ======================================== */

.tags-list {
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.tag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.tag-item:last-child {
    border-bottom: none;
}

.tag-color-preview {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.5rem;
}

/* ========================================
   Modal
   ======================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* ========================================
   Viewer - Split Layout
   ======================================== */

.viewer-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.viewer-header {
    background: var(--card-bg);
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.viewer-header h2 {
    font-size: 1.1rem;
    flex: 1;
}

.viewer-controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

#page-info {
    font-size: 0.9rem;
    color: var(--secondary-color);
}

#zoom-level, #img-zoom-level {
    font-size: 0.9rem;
    min-width: 50px;
    text-align: center;
}

.split-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.split-panel {
    overflow: auto;
}

.split-left {
    flex: 0 0 60%;
    background: #525659;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Remove scroll da div left */
}

.split-left .viewer-content-wrapper {
    flex: 1;
    overflow: auto; /* Scroll principal aqui */
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    cursor: default;
    min-height: 100%;
}

/* Modos de Cursor */
.cursor-select { cursor: text !important; }
.cursor-pan { cursor: grab !important; }
.cursor-pan:active { cursor: grabbing !important; }
.cursor-draw { cursor: crosshair !important; }

.split-resizer {
    width: 10px;
    background: #e0e0e0;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.split-resizer:hover {
    background: var(--primary-color);
}

.resizer-handle {
    width: 4px;
    height: 40px;
    background: #999;
    border-radius: 2px;
}

.split-right {
    flex: 0 0 40%;
    background: var(--bg-color);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.viewer-content {
    width: 100%;
    min-height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    overflow: auto;
    position: relative;
    padding: 20px;
}

#pdf-render {
    max-width: none;
    height: auto;
    display: block;
    position: relative;
}

#image-render {
    max-width: none;
    height: auto;
    transition: transform 0.2s;
    transform-origin: top left;
    display: block;
}

.not-supported {
    color: white;
    font-size: 1.2rem;
}

/* ========================================
   Annotations
   ======================================== */

.annotations-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.annotation-chip {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    background: var(--primary-color);
    color: white;
    border-radius: 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.annotation-chip:hover {
    opacity: 0.8;
}

.annotation-chip .remove-chip {
    cursor: pointer;
    font-weight: bold;
    margin-left: 0.2rem;
}

.annotations-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.annotation-box {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.annotation-box h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.annotation-box p {
    color: var(--text-color);
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.annotation-meta {
    font-size: 0.75rem;
    color: var(--secondary-color);
    margin-top: 0.5rem;
}

.annotation-form {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.annotation-form.hidden {
    display: none;
}

.annotation-form-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* ========================================
   Utilities
   ======================================== */

.hidden {
    display: none !important;
}
