:root {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --danger-color: #ef4444;
    --font-family: 'Inter', sans-serif;
    --header-height: 70px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Toolbar */
.toolbar {
    height: var(--header-height);
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.logo i {
    color: var(--accent-color);
}

.actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

/* Editor Workspace */
.editor-workspace {
    flex: 1;
    overflow-y: auto;
    background-color: #0b1120;
    position: relative;
    padding: 40px;
    display: flex;
    justify-content: center;
}

#pdf-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 1000px;
    /* Limit max width for readability */
}

/* Empty State */
.empty-state {
    text-align: center;
    margin-top: 100px;
    color: var(--text-secondary);
    animation: fadeIn 0.5s ease;
}

.empty-state .icon-box {
    font-size: 4rem;
    margin-bottom: 24px;
    opacity: 0.5;
}

.empty-state h2 {
    color: var(--text-primary);
    margin-bottom: 12px;
}

.empty-state p {
    margin-bottom: 24px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* PDF Page Container */
.pdf-page-container {
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    background-color: white;
    /* PDF pages are usually white */
    transition: transform 0.3s ease;
}

.pdf-canvas {
    display: block;
    width: 100%;
    /* Ensure canvas scales */
    height: auto;
}

/* Text Layer Overlay */
.text-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    /* Let clicks pass through to canvas if needed, but text needs pointer events */
}

/* Text Element Wrapper (Draggable & Positioned) */
.text-wrapper {
    position: absolute;
    min-width: 100px;
    z-index: 100;
    border: 1px dashed transparent;
    /* Hidden by default */
}

/* Show border and controls when active */
.text-wrapper.active {
    border-color: var(--accent-color);
    z-index: 1000;
    /* Bring to front */
}

.text-wrapper:hover {
    /* Optional: Show border on hover even if not selected? User asked for "only when I click", so maybe avoiding hover is safer. */
    /* border-color: rgba(59, 130, 246, 0.3); */
}

/* Inner Editable Text */
.editable-text {
    font-family: 'Helvetica', sans-serif;
    font-size: 16px;
    color: #000;
    padding: 4px;
    border: 1px dashed transparent;
    cursor: text;
    outline: none;
    line-height: 1.2;
    white-space: pre-wrap;
    min-height: 1em;
    /* Ensure height if empty */
}

.editable-text:empty::before {
    content: "Type here...";
    color: var(--text-secondary);
    font-style: italic;
    pointer-events: none;
    display: inline-block;
}

.text-wrapper.active .editable-text {
    background-color: rgba(59, 130, 246, 0.05);
}

/* Delete Button - Default Hidden */
.delete-btn {
    position: absolute;
    top: -30px;
    right: -10px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 1001;
}

/* Drag Handle - Default Hidden */
.drag-handle {
    position: absolute;
    top: -30px;
    left: -10px;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    cursor: move;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 1001;
}

/* Show controls when active */
.text-wrapper.active .delete-btn,
.text-wrapper.active .drag-handle {
    display: flex;
}