:root {
    --primary: #4f46e5;
    --primary-glow: rgba(79, 70, 229, 0.4);
    --bg-dark: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #0ea5e9;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

#app {
    display: grid;
    grid-template-columns: 350px 1fr;
    height: 100vh;
}

/* Glassmorphism Styles */
.glass {
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.glass-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    border-radius: 8px;
    padding: 10px 15px;
    width: 100%;
    outline: none;
    transition: var(--transition);
}

.glass-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* Sidebar */
.sidebar {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 100;
}

.sidebar-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.template-selector label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Fields List */
.fields-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.fields-list::-webkit-scrollbar {
    width: 4px;
}

.fields-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.field-item {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.field-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.field-item.active {
    background: rgba(79, 70, 229, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.2);
}

.field-item .label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    display: block;
}

.field-item .type {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-field-input {
    font-size: 14px;
    padding: 8px 12px;
}

/* Main Content */
.main-content {
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    overflow-x: auto;
    background: radial-gradient(circle at top right, rgba(79, 70, 229, 0.1), transparent);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Better mobile/trackpad smoothness */
}

.viewer-container {
    padding: 0;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    overflow: hidden;
    /* Ratio calculation for standard A4 might happen in JS */
}

.pdf-wrapper {
    position: relative;
    background: white;
    margin: 0 auto;
}

#pdf-canvas {
    display: block;
    max-width: 100%;
}

.field-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Allows interacting with children only */
}

/* Overlay Inputs */
.overlay-input {
    position: absolute;
    pointer-events: all;
    background: rgba(79, 70, 229, 0.05);
    border: 1px dashed rgba(79, 70, 229, 0.3);
    border-radius: 2px;
    font-size: inherit;
    padding: 0 4px;
}

.overlay-input:focus {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    color: black;
    z-index: 10;
}

.overlay-input[type="checkbox"] {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-input[type="checkbox"]:checked {
    background: var(--primary);
}

.overlay-input[type="checkbox"]:checked::after {
    content: '✓';
    color: white;
    font-size: 15px;
}

/* Buttons */
.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.btn {
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px var(--primary-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Global Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Status Bar */
.status-bar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-muted);
}