/* --- Global Reset & CSS Variables --- */
:root {
    --bg-main: #eef4ff;
--primary: #4f46e5;
--primary-hover: #4338ca;
--primary-light: #eef2ff;
    --bg-surface: #ffffff;
    --bg-dark-gray: #0f172a;
    
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --accent-crop: #f59e0b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 4px;
    --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);

    min-height: 100vh;

    display: block;

    overflow-x: hidden;
    overflow-y: auto;
}

/* --- Container App Layout --- */
.app-container {
    display: flex;
    flex-direction: column;

    width: 100%;

    min-height: 100vh;

    overflow: visible;
}

/* --- Header Area --- */
.app-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    box-shadow: var(--shadow-sm);
    background:linear-gradient(
        135deg,
        #4f46e5,
        #2563eb
    );

    color:white;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    color: #ffffff;
}
.logo i {
    font-size: 22px;
    color:white;
}
.logo h1 {
    font-size: 20px;
    font-weight: 700;
    color: white;
}
.logo h1 span {
    color: var(--primary);
}

.file-info-display {
    display: flex;
    align-items: center;
    /* text-align: center; */
    gap: 8px;
    background-color: var(--primary-light);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    /* max-width: 300px; */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Workspace Structure --- */
.app-workspace {
    position: relative;

    display: grid;

    grid-template-columns:
        minmax(0,1fr)
        340px;

    gap: 24px;

    padding: 24px;

    overflow: visible;
}

/* --- Left Side: PDF Viewer Arena --- */
.preview-area {
    background-color: transparent;

    display: flex;
    flex-direction: column;

    position: relative;

    overflow: visible;

    min-width: 0;
}

/* --- Modern Drag & Drop Zone --- */
.drop-zone {
    flex: 1;
    margin: 32px;
    /* border: 2px dashed #94a3b8; */
    /* background-color: var(--bg-surface); */
    border-radius: var(--radius-lg);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    background:
    linear-gradient(
        135deg,
        #ffffff,
        #f8faff
    );

    box-shadow:
    0 20px 60px rgba(79,70,229,.12);

    border:2px dashed #6366f1;
}

.drop-zone.dragover {
    border-color: var(--primary);
    background-color: var(--primary-light);
    transform: scale(1.01);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
}

.icon-circle {
    width: 80px;
    height: 80px;
    background-color: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.icon-circle i {
    font-size: 36px;
    color: var(--primary);
}

.drop-zone h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--bg-dark-gray);
    margin-bottom: 8px;
}

.drop-zone p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 16px;
}

.file-spec {
    font-size: 12px;
    color: var(--text-muted);
    background-color: var(--bg-main);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
}

/* --- Live Workbench Viewport Container --- */
.workbench {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.canvas-viewport-container {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px;
    position: relative;
}

.interactive-wrapper {
    position: relative;
    box-shadow: var(--shadow-lg);
    background-color: var(--bg-surface);
    display: inline-block;
    user-select: none;
}

#pdfCanvas {
    display: block;
    max-width: 100%;
}

/* --- Interactive Crop Box Engine CSS Layer --- */
.crop-box-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: 5;
}

.crop-resizer {
    position: absolute;
    /* border: 2px solid var(--accent-crop); */
    /* box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45); */
    /* background-color: transparent; */
    cursor: move;
    box-sizing: border-box;
    border:3px solid #f59e0b;

    background:
    rgba(245,158,11,.12);

    /* backdrop-filter: blur(2px); */

    box-shadow:
    0 0 0 9999px rgba(0,0,0,.35);
}

/* Composition Grid Guide Rules Inside Crop Box */
.crop-grid-line {
    position: absolute;
    border-style: dashed;
    border-color: rgba(255, 255, 255, 0.35);
    pointer-events: none;
}
.grid-h1 { top: 33.33%; left: 0; width: 100%; border-width: 1px 0 0 0; }
.grid-h2 { top: 66.66%; left: 0; width: 100%; border-width: 1px 0 0 0; }
.grid-v1 { left: 33.33%; top: 0; height: 100%; border-width: 0 0 0 1px; }
.grid-v2 { left: 66.66%; top: 0; height: 100%; border-width: 0 0 0 1px; }

/* Positional Drag Handles Setup */
.handle {
    position: absolute;
    width: 11px;
    height: 11px;
    background-color: var(--accent-crop);
    border: 1.5px solid #ffffff;
    border-radius: 50%;
    z-index: 6;
}

/* Corner Handles */
.handle-tl { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-tr { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-br { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* Edge Handles */
.handle-t { top: -6px; left: calc(50% - 6px); cursor: ns-resize; border-radius: var(--radius-sm); width: 14px; }
.handle-b { bottom: -6px; left: calc(50% - 6px); cursor: ns-resize; border-radius: var(--radius-sm); width: 14px; }
.handle-l { left: -6px; top: calc(50% - 6px); cursor: ew-resize; border-radius: var(--radius-sm); height: 14px; }
.handle-r { right: -6px; top: calc(50% - 6px); cursor: ew-resize; border-radius: var(--radius-sm); height: 14px; }

/* --- Preview Navigation Bottom Bar Toolbar --- */
.preview-toolbar {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    height: 56px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 6;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.02);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-indicator {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    min-width: 100px;
    text-align: center;
}

/* --- Right Control Sidebar Panel --- */
.settings-panel {
    width: 100%;

    background: #fff;

    border: 1px solid #e5e7eb;

    border-radius: 20px;

    padding: 24px;

    gap: 28px;

    display: flex;
    flex-direction: column;

    overflow: visible;

    position: sticky;

    top: 90px;

    height: fit-content;

    box-shadow:
        0 10px 30px rgba(0,0,0,.08);
}

.hero-banner{
    max-width:1400px;
    margin:20px auto;
}


.tool-intro{
    background:white;

    padding:24px;

    border-radius:16px;

    /* margin-bottom:20px; */

    box-shadow:
        0 8px 20px rgba(0,0,0,.05);
}

.tool-intro h1{
    font-size:30px;
    margin-bottom:5px;
    color:var(--primary);
    /* font-color:var(--bg-dark-gray); */
}

.tool-intro p{
    color:#64748b;
    line-height:0.5;
}

.panel-section h2 {
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bg-dark-gray);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-section h2 i {
    color: var(--text-muted);
    font-size: 16px;
}

.section-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 16px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Interactive Radio Cards */
.radio-card-label {
    cursor: pointer;
    display: block;
}

.radio-card-label input[type="radio"] {
    display: none;
}

.radio-card-content {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    gap: 12px;
    transition: var(--transition-smooth);
}

.radio-card-content i {
    font-size: 18px;
    color: var(--text-muted);
    margin-top: 2px;
}

.radio-card-content .title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 3px;
}

.radio-card-content .desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
}

.radio-card-label input[type="radio"]:checked + .radio-card-content {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.radio-card-label input[type="radio"]:checked + .radio-card-content i {
    color: var(--primary);
}

/* --- View Zoom Controls Architecture --- */
.zoom-controls-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-main);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.zoom-display {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    width: 60px;
    text-align: center;
}

.fit-buttons-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* --- Button Framework Styles --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    white-space: nowrap;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-md { padding: 10px 18px; }
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}
.btn-primary:hover:not(:disabled) { background-color: var(--primary-hover); }

.btn-secondary {
    background-color: var(--bg-main);
    color: var(--text-main);
    border-color: var(--border-color);
}
.btn-secondary:hover:not(:disabled) {
    background-color: #e2e8f0;
}

.btn-outline {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-color);
}
.btn-outline:hover:not(:disabled) {
    background-color: var(--bg-main);
    border-color: #cbd5e1;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition-smooth);
}
.btn-icon:hover:not(:disabled) {
    background-color: var(--bg-main);
}
.btn-icon:disabled, .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.conversion-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* --- Processing Overlay & Micro components --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.2s ease;
}

.spinner-container {
    background-color: var(--bg-surface);
    padding: 32px 48px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--primary-light);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#loadingText {
    font-size: 15px;
    font-weight: 600;
    color: var(--bg-dark-gray);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notifications Toast Alerts */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #0f172a;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 150;
    transition: var(--transition-smooth);
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

/* --- Responsive Adaptations Layout Breakpoints --- */
@media (max-width: 1024px) {
    .app-workspace {
        flex-direction: column;
    }
    .settings-panel {
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 1px solid var(--border-color);
        flex-direction: row;
        justify-content: space-between;
    }
    .panel-section {
        flex: 1;
    }
    .conversion-actions {
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .settings-panel {
        flex-direction: column;
    }
    .app-header {
        padding: 0 16px;
    }
    .canvas-viewport-container {
        padding: 16px;
    }
}

/* ===== UI Improvements ===== */
.drop-zone{
    position:relative;
    overflow:hidden;
    box-shadow:0 15px 40px rgba(0,0,0,.08);
}

.drop-zone::before{
    content:'';
    position:absolute;
    inset:0;
    background:linear-gradient(135deg, rgba(37,99,235,.05), transparent);
    pointer-events:none;
}

.drop-zone:hover{
    border-color:var(--primary);
    transform:translateY(-2px);
    box-shadow:0 20px 50px rgba(37,99,235,.12);
}

.crop-resizer{
    border-width:3px;
    background:rgba(245,158,11,.08);
}

.crop-resizer::before{
    content:'Selected Area';
    position:absolute;
    top:-34px;
    left:0;
    background:var(--accent-crop);
    color:#fff;
    padding:4px 10px;
    border-radius:6px;
    font-size:12px;
    font-weight:600;
}

.handle{
    width:14px;
    height:14px;
}

.settings-panel{
    box-shadow:-6px 0 20px rgba(0,0,0,.04);
}

.btn-primary{
    box-shadow:0 8px 20px rgba(37,99,235,.25);
}

.crop-resizer {
    border: 3px solid #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}

.crop-resizer::before {
    content: "Selected Area";
    position: absolute;
    top: -32px;
    left: 0;
    background: #f59e0b;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.handle {
    width: 14px;
    height: 14px;
}