/* WordPress Wrapper */
.conclave-program-wrapper {
    position: relative;
    width: 100%;
    min-height: 600px;
}

/* Text-based icons */
.conclave-program-wrapper .icon-text {
    font-size: 20px;
    line-height: 1;
    color: #4a5568;
    display: inline-block;
}

.conclave-program-wrapper .toolbar-btn .icon-text {
    font-size: 18px;
    color: #4a5568;
}

.conclave-program-wrapper .toolbar-btn:hover .icon-text {
    color: #1a5f7a;
}

.conclave-program-wrapper .action-btn .icon-text {
    font-size: 16px;
    margin-right: 6px;
}

.conclave-program-wrapper .search-container button .icon-text {
    font-size: 16px;
    color: white;
}

.conclave-program-wrapper .toggle-sidebar .icon-text {
    font-size: 16px;
    color: #4a5568;
}

.conclave-program-wrapper .toggle-sidebar:hover .icon-text {
    color: white;
}

/* Multi-field notes (for page 8) */
.multi-notes-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 0 0 8px 8px;
    pointer-events: auto;
}

.multi-note-field {
    margin-bottom: 12px;
}

.multi-note-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a5f7a;
    margin-bottom: 4px;
}

.multi-note-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.multi-note-field input:focus {
    outline: none;
    border-color: #1a5f7a;
    box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.1);
}

.multi-note-field input::placeholder {
    color: #a0aec0;
}

.conclave-program-wrapper .app-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    width: 100%;
}

/* CSS Variables */
:root {
    --primary-color: #1a5f7a;
    --primary-dark: #134b61;
    --secondary-color: #f5a623;
    --accent-color: #57c5b6;
    --background: #f5f7fa;
    --surface: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --sidebar-width: 300px;
    --toolbar-height: 56px;
    --transition: 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* WordPress-specific: override when inside wrapper */
.conclave-program-wrapper .app-container {
    height: 100%;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform var(--transition), width var(--transition);
    z-index: 100;
}

.sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    width: 0;
    min-width: 0;
}

.sidebar-header {
    padding: 24px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Search */
.search-container {
    padding: 16px 20px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.search-container input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.1);
}

.search-container button {
    padding: 10px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition);
}

.search-container button:hover {
    background: var(--primary-dark);
}

.search-results {
    max-height: 200px;
    overflow-y: auto;
    border-bottom: 1px solid var(--border-color);
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--background);
}

.search-result-item .page-num {
    color: var(--primary-color);
    font-weight: 600;
    margin-right: 8px;
}

.search-result-item .snippet {
    color: var(--text-secondary);
}

.search-result-item mark {
    background: var(--secondary-color);
    color: var(--text-primary);
    padding: 0 2px;
    border-radius: 2px;
}

/* Table of Contents */
.toc {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.toc h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 20px;
    margin-bottom: 12px;
}

.toc ul {
    list-style: none;
}

.toc-section {
    margin-bottom: 16px;
}

.toc-section-title {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 20px;
    background: var(--background);
}

.toc-section ul {
    padding: 4px 0;
}

.toc a {
    display: block;
    padding: 8px 20px 8px 32px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background var(--transition), color var(--transition);
    border-left: 3px solid transparent;
}

.toc a:hover {
    background: var(--background);
    color: var(--primary-color);
}

.toc a.active {
    background: rgba(26, 95, 122, 0.1);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 500;
}

.toc a.notes-link::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--secondary-color);
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
}

/* Sidebar Actions */
.sidebar-actions {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
}

.action-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.action-btn.danger:hover {
    background: #e53e3e;
    border-color: #e53e3e;
}

/* Toggle Sidebar Button */
.toggle-sidebar {
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
    z-index: 10;
}

.toggle-sidebar:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.sidebar.collapsed .toggle-sidebar {
    right: -48px;
}

.sidebar.collapsed .toggle-sidebar svg {
    transform: rotate(180deg);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Toolbar */
.toolbar {
    height: var(--toolbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    gap: 16px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-center {
    flex: 1;
    text-align: center;
}

.toolbar-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.toolbar-btn:hover {
    background: var(--background);
    color: var(--primary-color);
}

.toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.page-info input {
    width: 48px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.875rem;
}

.page-info input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.page-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.zoom-level {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 48px;
    text-align: center;
}

.mobile-only {
    display: none;
}

/* Viewer Container */
.viewer-container {
    flex: 1;
    overflow: auto;
    background: var(--background);
    display: flex;
    justify-content: center;
    padding: 24px;
}

.pdf-wrapper {
    position: relative;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    max-width: 100%;
    margin: 0 auto;
}

#pdfCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Notes Overlay */
.notes-overlay {
    position: absolute;
    top: 22%;
    left: 8%;
    right: 8%;
    bottom: 4%;
    background: transparent;
    display: flex;
    flex-direction: column;
    padding: 0;
    pointer-events: none;
}

.notes-overlay.hidden {
    display: none;
}

.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(26, 95, 122, 0.9);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    pointer-events: auto;
}

.notes-header h3 {
    font-size: 0.875rem;
    color: white;
}

.notes-hint {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 8px;
}

#notesTextarea {
    flex: 1;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: none;
    background: rgba(255, 255, 255, 0.92);
    transition: background var(--transition);
    pointer-events: auto;
}

#notesTextarea:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.98);
}

#notesTextarea::placeholder {
    color: var(--text-muted);
}

/* Loading Indicator */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.hidden {
    display: block;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-secondary {
    background: var(--background);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: #e53e3e;
    border: none;
    color: white;
}

.btn-danger:hover {
    background: #c53030;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
        --toolbar-height: 50px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .toggle-sidebar {
        display: none;
    }

    .mobile-only {
        display: flex;
    }

    .viewer-container {
        padding: 12px;
    }

    .pdf-wrapper {
        border-radius: var(--radius-md);
    }

    .notes-overlay {
        top: 12%;
        left: 5%;
        right: 5%;
        bottom: 3%;
    }

    .notes-header {
        padding: 6px 10px;
        margin-bottom: 6px;
    }

    .notes-header h3 {
        font-size: 0.8rem;
    }

    .notes-hint {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    #notesTextarea {
        padding: 12px;
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .multi-notes-container {
        padding: 10px;
        pointer-events: auto;
    }

    .multi-note-field {
        margin-bottom: 10px;
    }

    .multi-note-field label {
        font-size: 0.75rem;
    }

    .multi-note-field input {
        padding: 8px 10px;
        font-size: 16px;
    }

    .toolbar {
        padding: 0 8px;
        gap: 8px;
    }

    .toolbar-center {
        display: none;
    }

    .toolbar-btn {
        width: 36px;
        height: 36px;
    }

    .page-info input {
        width: 40px;
        padding: 4px 6px;
        font-size: 0.8rem;
    }

    .zoom-level {
        font-size: 0.8rem;
        min-width: 40px;
    }
}

/* Responsive - Phone */
@media (max-width: 480px) {
    :root {
        --toolbar-height: 46px;
    }

    .viewer-container {
        padding: 8px;
    }

    .pdf-wrapper {
        border-radius: var(--radius-sm);
    }

    .notes-overlay {
        top: 10%;
        left: 3%;
        right: 3%;
        bottom: 2%;
    }

    .notes-header {
        padding: 5px 8px;
        margin-bottom: 4px;
        flex-direction: column;
        gap: 2px;
        align-items: flex-start;
    }

    .notes-header h3 {
        font-size: 0.75rem;
    }

    .notes-hint {
        font-size: 0.6rem;
    }

    .multi-notes-container {
        padding: 8px;
        pointer-events: auto;
    }

    .multi-note-field {
        margin-bottom: 8px;
    }

    .multi-note-field label {
        font-size: 0.7rem;
        margin-bottom: 2px;
    }

    .multi-note-field input {
        padding: 8px;
        font-size: 16px;
    }

    #notesTextarea {
        padding: 10px;
        font-size: 16px; /* Prevents iOS zoom on focus */
        line-height: 1.4;
    }

    .toolbar {
        padding: 0 6px;
        gap: 4px;
    }

    .toolbar-btn {
        width: 32px;
        height: 32px;
    }

    .toolbar-btn svg {
        width: 20px;
        height: 20px;
    }

    .page-info {
        font-size: 0.75rem;
    }

    .page-info input {
        width: 36px;
        padding: 3px 4px;
        font-size: 0.75rem;
    }

    .toolbar-right {
        gap: 4px;
    }

    .zoom-level {
        display: none;
    }

    .sidebar-header {
        padding: 16px;
    }

    .sidebar-header h1 {
        font-size: 1.25rem;
    }

    .search-container {
        padding: 12px 16px;
    }

    .sidebar-actions {
        padding: 12px 16px;
    }

    .action-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .toc a {
        padding: 6px 16px 6px 24px;
        font-size: 0.8rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .toolbar-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .action-btn {
        min-height: 44px;
    }

    #notesTextarea {
        font-size: 16px; /* Prevents iOS zoom */
    }

    .search-container input {
        font-size: 16px;
    }

    .page-info input {
        font-size: 16px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .toolbar,
    .toggle-sidebar {
        display: none !important;
    }

    .main-content {
        width: 100%;
    }

    .viewer-container {
        padding: 0;
        overflow: visible;
    }

    .pdf-wrapper {
        box-shadow: none;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
