/*
 * === PRO PDF EDITOR STYLESHEET (Updated Color Scheme) ===
 */

/* 1. Root variables */
:root {
    /* --- NEW COLORS --- */
    --bg-primary: #f8f9fa; /* Light background for overall app */
    --bg-secondary: #ffffff; /* White background for header/cards */
    --bg-light-gray: #e0e6ed; /* Light gray for borders, inactive elements */
    --text-dark: #343a40; /* Dark text for primary content */
    --text-muted: #6c757d; /* Muted text for secondary info */
    
    --header-bg: #5f9ea0; /* Cadet Blue for Header */
    --header-text: #ffffff; /* White text for header */

    --accent-blue-btn: #2196f3; /* Bright Blue for "Create New" button */
    --accent-blue-btn-hover: #1976d2;

    --status-active-bg: #dc3545; /* Red for "Active" status */
    --status-active-text: #ffffff;
    --status-archived-bg: #6c757d; /* Gray for "Archived" status */
    --status-archived-text: #ffffff;

    --table-header-bg: #5f9ea0; /* Cadet Blue for table headers */
    --table-header-text: #ffffff;

    /* Original PDF Editor specific colors (adjust as needed if they clash visually) */
    --field-bg-text: rgba(255, 255, 0, 0.2);
    --field-border-text: rgba(255, 255, 0, 0.7);
    --field-bg-check: rgba(0, 123, 255, 0.2);
    --field-border-check: rgba(0, 123, 255, 0.7);

    /* Original accent-blue for toolbar hover and focus, keep for now */
    --editor-accent-blue: #007bff;
    --editor-accent-blue-hover: #0069d9;
    --editor-accent-green: #28a745; /* For Export */
    --editor-accent-green-hover: #218838;
}

/* 2. Global & Font Setup */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary); /* Use new primary background */
    color: var(--text-dark); /* Use new dark text */
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* 3. Main Application Layout */
.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    background-color: var(--bg-secondary); /* Use new secondary background */
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--bg-light-gray); /* Use new border color */
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); /* Lighter shadow */
    z-index: 100;
}

.app-header .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--editor-accent-blue); /* Keep editor accent blue for logo icon */
}

.app-header .logo i {
    font-size: 1.5rem;
}

.app-header .logo h1 {
    font-size: 1.25rem;
    margin: 0;
    font-weight: 700;
    color: var(--text-dark); /* Use new dark text */
}

/* 4. "Call to Action" Buttons */
.header-controls {
    position: relative;
    display: flex;
    gap: 10px;
}

.header-controls input[type="file"] {
    display: none;
}

.cta-button {
    background-color: var(--editor-accent-blue); /* Keep editor accent blue for now */
    color: white;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cta-button:hover {
    background-color: var(--editor-accent-blue-hover);
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
}

.cta-button.disabled {
    background-color: var(--bg-light-gray); /* Use new light gray */
    color: var(--text-muted); /* Use new muted text */
    cursor: not-allowed;
}

.cta-button.disabled:hover {
    background-color: var(--bg-light-gray);
    box-shadow: none;
}

/* Export Button Style */
.export-button {
    background-color: var(--editor-accent-green);
}
.export-button:hover {
    background-color: var(--editor-accent-green-hover);
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
}


/* 5. Main Content Area */
.content-area {
    width: 100%;
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

/* 6. Empty State (Before Upload) */
#empty-state {
    text-align: center;
    padding: 4rem 2rem;
    border: 2px dashed var(--bg-light-gray); /* Use new border color */
    border-radius: 8px;
    color: var(--text-muted); /* Use new muted text */
}

/* 7. PDF Container & Page Styles */
#pdf-container:not(:empty) + #empty-state {
    display: none;
}

.pdf-page {
    position: relative;
    margin-bottom: 1.5rem;
    border: 1px solid var(--bg-light-gray); /* Use new border color */
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); /* Lighter shadow */
    background-color: white; 
    border-radius: 4px;
}

.pdf-page canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* 8. Toolbar Styles */
.tool-bar {
    position: fixed;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    background-color: var(--bg-secondary); /* Use new secondary background */
    border-radius: 8px;
    border: 1px solid var(--bg-light-gray); /* Use new border color */
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); /* Lighter shadow */
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    z-index: 1000;
}

.tool-bar button {
    background-color: transparent;
    border: 2px solid var(--bg-light-gray); /* Use new border color */
    color: var(--text-muted); /* Use new muted text */
    font-size: 1.2rem;
    width: 45px;
    height: 45px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-bar button:hover {
    border-color: var(--editor-accent-blue);
    color: var(--editor-accent-blue);
}

.tool-bar button.active {
    background-color: var(--editor-accent-blue);
    border-color: var(--editor-accent-blue);
    color: white;
}

/* 9. Field Wrapper & Controls Styles */
.field-wrapper {
    position: absolute;
    border: 1px dashed transparent;
    transition: border-color 0.2s ease;
    z-index: 10;
    overflow: visible;
    min-width: 20px;
    min-height: 20px;
}

.field-wrapper:hover {
    border-color: var(--editor-accent-blue);
    cursor: move;
}

/* Field Controls (Title + Delete) */
.field-controls {
    position: absolute;
    top: -22px;
    left: 0;
    display: none;
    z-index: 20;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    padding: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.field-wrapper:hover .field-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.field-reference-title {
    background-color: var(--bg-primary);
    border: 1px solid var(--bg-light-gray);
    color: var(--text-dark);
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 2px;
    margin-left: 2px;
}
.field-reference-title::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.delete-btn {
    position: relative;
    top: 0;
    right: 0;
    width: 18px;
    height: 18px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    border: 1px solid white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    cursor: pointer;
}

/* *** NEW *** Resize Handle */
.resize-handle-se {
    position: absolute;
    bottom: -7px;
    right: -7px;
    width: 14px;
    height: 14px;
    background: var(--editor-accent-blue);
    border: 1px solid white;
    border-radius: 50%;
    cursor: se-resize; /* South-East resize cursor */
    z-index: 25;
    display: none; /* Hide by default */
}

.field-wrapper:hover .resize-handle-se {
    display: block; /* Show on hover */
}

/* 10. Field Styles */
.text-field {
    border: 1px dashed var(--field-border-text);
    font-size: 16px; 
    padding: 4px;
    box-sizing: border-box; 
    border-radius: 2px;
    color: #000;
    background-color: var(--field-bg-text);
    font-family: 'Inter', sans-serif;
    
    width: 100%;
    height: 100%;
    resize: none; 
    cursor: text;
    overflow: auto; /* Show scrollbar if text is too big */
}

.text-field:focus {
    outline: 2px solid var(--editor-accent-blue);
    background-color: rgba(255, 255, 0, 0.3);
}

.checkbox-field {
    background-color: var(--field-bg-check);
    border: 1px dashed var(--field-border-check);
    box-sizing: border-box;
    margin: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* 11. Export Mode */
body.export-mode .app-header,
body.export-mode .tool-bar,
body.export-mode .field-controls,
body.export-mode .resize-handle-se { /* Hide handle on export */
    display: none;
}

body.export-mode .field-wrapper {
    border: none !important;
    resize: none !important;
    overflow: hidden !important;
}

body.export-mode .text-field {
    border: none !important;
    background-color: transparent !important;
    overflow: hidden !important;
}

body.export-mode .checkbox-field {
    border: none !important;
    background-color: transparent !important;
}

/* --- ADDED STYLES FOR TEMPLATE VIEW --- */
/* (These are from the previous color update, unused by the editor but kept for consistency) */
.template-header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.template-header h2 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
}

.create-template-btn {
    background-color: var(--accent-blue-btn);
    color: white;
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.create-template-btn:hover {
    background-color: var(--accent-blue-btn-hover);
}

.status-tabs {
    display: flex;
    gap: 10px;
    margin: -1rem 2rem 2rem;
    position: relative;
    top: -10px;
    z-index: 10;
}

.status-tab {
    background-color: var(--bg-secondary);
    color: var(--text-dark);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid var(--bg-light-gray);
}

.status-tab.active-status {
    background-color: var(--status-active-bg);
    color: var(--status-active-text);
    border-color: var(--status-active-bg);
}

.status-tab.archived-status {
    background-color: var(--status-archived-bg);
    color: var(--status-archived-text);
    border-color: var(--status-archived-bg);
}

.status-tab span.count {
    font-weight: 700;
    margin-left: 5px;
}

.search-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.5rem;
    padding: 0 2rem;
}

.search-input-wrapper {
    display: flex;
    border: 1px solid var(--bg-light-gray);
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--bg-secondary);
}

.search-input-wrapper input {
    border: none;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    width: 250px;
    outline: none;
    color: var(--text-dark);
    background-color: transparent;
}

.search-input-wrapper input::placeholder {
    color: var(--text-muted);
}

.search-input-wrapper .clear-search,
.search-input-wrapper .search-button {
    background-color: transparent;
    border: none;
    padding: 0 10px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.search-input-wrapper .clear-search:hover,
.search-input-wrapper .search-button:hover {
    color: var(--accent-blue-btn);
}

.search-input-wrapper .search-button {
    background-color: var(--header-bg);
    color: var(--header-text);
}

.search-input-wrapper .search-button:hover {
    background-color: var(--accent-blue-btn-hover);
    color: white;
}


table.template-table {
    width: calc(100% - 4rem);
    margin: 0 2rem;
    border-collapse: collapse;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

table.template-table th,
table.template-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--bg-light-gray);
}

table.template-table th {
    background-color: var(--table-header-bg);
    color: var(--table-header-text);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}

table.template-table tr:last-child td {
    border-bottom: none;
}

table.template-table tbody tr:hover {
    background-color: #f1f3f5;
}

table.template-table a {
    color: var(--editor-accent-blue);
    text-decoration: none;
}

table.template-table a:hover {
    text-decoration: underline;
}