:root {
    /* Theme Variables */
    --bg-primary: #f5f7fb;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --primary: #4f46e5;
    --primary-light: #e0e7ff;
    --primary-dark: #3730a3;
    --accent: #ec4899;
    --border: #e2e8f0;
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.02);
    
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

[data-theme="dark"] {
    --bg-primary: #0b0f19;
    --bg-card: #151d30;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary: #6366f1;
    --primary-light: #1e293b;
    --primary-dark: #4f46e5;
    --accent: #ec4899;
    --border: #1e293b;
    --shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    
    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

header {
    padding: 1.5rem 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.theme-toggle {
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    padding: 0.6rem;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
    color: var(--text-primary);
}

.theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.theme-toggle .sun-icon { display: none; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }
[data-theme="dark"] .theme-toggle .sun-icon { display: block; }

/* Ad rails layout */
.ad-rail-left, .ad-rail-right {
    display: none;
    position: fixed;
    top: 140px;
    width: 160px;
    height: 600px;
    z-index: 99;
}
.ad-rail-left { left: calc(50% - 700px - 180px); }
.ad-rail-right { right: calc(50% - 700px - 180px); }
@media (min-width: 1720px) {
    .ad-rail-left, .ad-rail-right { display: block; }
}

.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem 3rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ad-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    overflow: hidden;
    width: 100%;
}

.ad-container::before {
    content: 'ADVERTISEMENT';
    font-size: 0.6rem;
    color: var(--text-secondary);
    position: absolute;
    top: 2px;
    letter-spacing: 0.1em;
}

.ad-top { position: relative; padding-top: 15px; min-height: 105px; width: 100%; }
.ad-bottom { position: relative; padding-top: 15px; min-height: 105px; margin-top: 2rem; width: 100%; }

/* Grid Layout */
.layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 992px) {
    .layout-grid {
        grid-template-columns: 380px 1fr;
    }
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    transition: var(--transition);
}

.card h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* Form Groups & Inputs */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}

.form-input, .form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Checkbox switches */
.switch-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.switch-group input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.switch-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}

/* Custom upload zones */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    background: var(--bg-primary);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    margin-bottom: 1rem;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

[data-theme="dark"] .upload-area:hover, [data-theme="dark"] .upload-area.dragover {
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    width: 38px;
    height: 38px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.upload-area:hover .upload-icon {
    color: var(--primary);
    transform: translateY(-2px);
}

.upload-text {
    font-weight: 600;
    font-size: 0.9rem;
}

.upload-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Small uploads for Signature & Seal */
.stamp-uploads-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.small-upload-box {
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 0.5rem;
    text-align: center;
    cursor: pointer;
    background: var(--bg-primary);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    position: relative;
}

.small-upload-box:hover, .small-upload-box.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

[data-theme="dark"] .small-upload-box:hover, [data-theme="dark"] .small-upload-box.dragover {
    background: rgba(99, 102, 241, 0.05);
}

.small-upload-icon {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.small-upload-box:hover .small-upload-icon {
    color: var(--primary);
}

.small-upload-text {
    font-size: 0.8rem;
    font-weight: 600;
}

/* File Listing Cards */
.file-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.file-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.file-details {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.file-icon {
    color: var(--primary);
    flex-shrink: 0;
}

.file-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.action-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-icon-btn:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* stamp preview card */
.stamp-preview-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    position: relative;
}

.stamp-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: capitalize;
}

.stamp-preview-img-wrapper {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    padding: 0.25rem;
}

.stamp-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}

.stamp-control-tools {
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

/* Action button for placing stamps */
.btn-stamp-action {
    width: 100%;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.btn-stamp-action:hover {
    background: var(--primary);
    color: white;
}

/* Main action button */
.btn-convert {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 1rem;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-convert:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.btn-convert:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Range Inputs */
.range-slider {
    width: 100%;
    accent-color: var(--primary);
    height: 6px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.range-val {
    font-size: 0.75rem;
    color: var(--text-secondary);
    float: right;
}

/* Progress panel */
.progress-panel {
    margin-top: 1.25rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border);
    display: none;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.progress-bar-container {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Alerts */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    display: none;
    line-height: 1.5;
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Privacy note */
.privacy-disclaimer {
    display: flex;
    gap: 0.75rem;
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.15);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.privacy-disclaimer svg {
    color: var(--success);
    flex-shrink: 0;
}

/* Workspace Preview Panel */
.workspace-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 600px;
    background: #0f172a;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    position: relative;
}

[data-theme="light"] .workspace-card {
    background: #e2e8f0;
    border-color: var(--border);
}

.workspace-toolbar {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    z-index: 10;
}

[data-theme="light"] .workspace-toolbar {
    background: rgba(248, 250, 252, 0.85);
    border-bottom-color: var(--border);
}

.toolbar-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #f8fafc;
    font-family: 'Outfit', sans-serif;
}

[data-theme="light"] .toolbar-title {
    color: var(--text-primary);
}

.toolbar-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

[data-theme="light"] .toolbar-btn {
    background: #ffffff;
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="light"] .toolbar-btn:hover {
    background: var(--bg-primary);
}

/* Page viewer container */
.pdf-viewer-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    max-height: 800px;
    scroll-behavior: smooth;
}

.pdf-page-wrapper {
    position: relative;
    background: #ffffff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    transition: transform 0.2s ease;
    max-width: 100%;
}

[data-theme="light"] .pdf-page-wrapper {
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
}

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

.pdf-page-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: auto;
    overflow: visible;
}

.page-number-tag {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.7);
    color: #f8fafc;
    padding: 0.2rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .page-number-tag {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    border-color: var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Placed Stamp Items */
.placed-stamp {
    position: absolute;
    border: 1.5px dashed transparent;
    cursor: move;
    user-select: none;
    touch-action: none;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1px;
}

.placed-stamp:hover, .placed-stamp.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.placed-stamp-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Resize and Delete Buttons on Placed Stamps */
.placed-stamp .stamp-delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    z-index: 10;
}

.placed-stamp .stamp-resize-handle {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border: 2px solid white;
    border-radius: 50%;
    cursor: nwse-resize;
    display: none;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.placed-stamp:hover .stamp-delete-btn, .placed-stamp.selected .stamp-delete-btn,
.placed-stamp:hover .stamp-resize-handle, .placed-stamp.selected .stamp-resize-handle {
    display: flex;
}

/* Workspace placeholder */
.viewer-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: #64748b;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
}

.placeholder-icon {
    width: 64px;
    height: 64px;
    stroke-width: 1.5;
    opacity: 0.4;
}

/* Details and FAQ cards */
.details-section {
    margin-top: 1.5rem;
}

.faq-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media (min-width: 768px) {
    .faq-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.faq-item h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.faq-item p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Standard Footer Styles */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.footer-info {
    display: flex;
    align-items: center;
    gap: 20px;
}
.current-time-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    color: var(--text-primary);
}
[data-theme="light"] .current-time-badge {
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(15, 23, 42, 0.08);
}
.text-center { text-align: center; }
.text-primary-color { color: var(--primary); }
.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}
.footer-link:hover {
    color: var(--primary);
}
