:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #8b5cf6;
    --bg-app: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-toolbar: #ffffff;
    --bg-page: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
    --bg-app: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-toolbar: #1e293b;
    --bg-page: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border: #334155;
    --border-light: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
}

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

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-app);
    color: var(--text-primary);
    transition: var(--transition);
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.left-sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.sidebar-tools {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tool-btn:hover {
    background: var(--border-light);
    color: var(--text-primary);
    transform: translateX(4px);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tool-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.tool-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.lang-select,
.font-select,
.font-size-select {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lang-select label,
.font-select label,
.font-size-select label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lang-select select,
.font-select select,
.font-size-select select {
    padding: 10px 12px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.lang-select select:hover,
.font-select select:hover,
.font-size-select select:hover {
    border-color: var(--primary);
}

.lang-select select:focus,
.font-select select:focus,
.font-size-select select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.new-page-btn,
.export-btn {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    margin-top: auto;
}

.new-page-btn:hover,
.export-btn:hover {
    background: var(--primary-hover);
    color: white;
    transform: translateX(4px);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-app);
}

.sticky-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-toolbar);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    z-index: 50;
    position: sticky;
    top: 0;
}

.toolbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.toolbar-btn:hover {
    background: var(--border-light);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.toolbar-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.toolbar-btn svg {
    width: 18px;
    height: 18px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

#textColor,
#highlightColor {
    width: 32px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    background: var(--bg-page);
    transition: var(--transition);
}

#textColor:hover,
#highlightColor:hover {
    border-color: var(--primary);
    transform: scale(1.1);
}

.spacing-controls select {
    padding: 6px 10px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

.spacing-controls select:hover {
    border-color: var(--primary);
}

.editor-container {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.a4-page {
    width: 210mm;
    min-height: 297mm;
    background: var(--bg-page);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    position: relative;
    transition: var(--transition);
    margin-bottom: 32px;
}

.a4-page:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: -16px;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    pointer-events: none;
}

.a4-page:hover {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.page-header {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    opacity: 0.6;
}

.editor-instance {
    min-height: 280mm;
    padding: 20mm;
    outline: none;
}

.editor-instance .ck-editor__main {
    min-height: 260mm;
}

.editor-instance .ck-editor__content {
    min-height: 260mm;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.8;
    counter-reset: h1;
}

.editor-instance .ck-editor__content p {
    margin-bottom: 16px;
}

/* Heading auto-numbering with CSS counters */
.editor-instance .ck-editor__content h1 {
    counter-reset: h2;
    font-size: 2.25rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
    color: var(--text-primary);
}

.editor-instance .ck-editor__content h1::before {
    counter-increment: h1;
    content: counter(h1) ". ";
    font-weight: 700;
    color: var(--primary);
    margin-right: 0.5rem;
}

.editor-instance .ck-editor__content h2 {
    counter-reset: h3;
    font-size: 1.875rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.875rem;
    color: var(--text-primary);
}

.editor-instance .ck-editor__content h2::before {
    counter-increment: h2;
    content: counter(h1) "." counter(h2) ". ";
    font-weight: 600;
    color: var(--primary);
    margin-right: 0.5rem;
}

.editor-instance .ck-editor__content h3 {
    counter-reset: h4;
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.editor-instance .ck-editor__content h3::before {
    counter-increment: h3;
    content: counter(h1) "." counter(h2) "." counter(h3) ". ";
    font-weight: 600;
    color: var(--primary);
    margin-right: 0.5rem;
}

.editor-instance .ck-editor__content h4 {
    counter-reset: h5;
    font-size: 1.25rem;
    font-weight: 500;
    margin-top: 1.25rem;
    margin-bottom: 0.625rem;
    color: var(--text-secondary);
}

.editor-instance .ck-editor__content h4::before {
    counter-increment: h4;
    content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) ". ";
    font-weight: 500;
    color: var(--primary);
    margin-right: 0.5rem;
}

.editor-instance .ck-editor__content h5 {
    counter-reset: h6;
    font-size: 1.125rem;
    font-weight: 500;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.editor-instance .ck-editor__content h5::before {
    counter-increment: h5;
    content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". ";
    font-weight: 500;
    color: var(--primary);
    margin-right: 0.5rem;
}

.editor-instance .ck-editor__content h6 {
    font-size: 1rem;
    font-weight: 500;
    margin-top: 0.875rem;
    margin-bottom: 0.375rem;
    color: var(--text-muted);
}

.editor-instance .ck-editor__content h6::before {
    counter-increment: h6;
    content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ". ";
    font-weight: 500;
    color: var(--primary);
    margin-right: 0.5rem;
}

/* Reset counters for nested editors (multiple pages) */
.editor-instance {
    counter-reset: h1;
}

.editor-instance .ck-editor__editable {
    min-height: 260mm !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

.editor-instance .ck-toolbar {
    display: none !important;
}

.page-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-toolbar);
    border-top: 1px solid var(--border);
}

.page-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px;
}

.page-tab {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.page-tab:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.page-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Page tab wrapper for delete button */
.page-tab-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-tab-wrapper.active .page-delete-btn {
    opacity: 1;
    visibility: visible;
}

/* Page delete button */
.page-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    flex-shrink: 0;
}

.page-tab-wrapper:hover .page-delete-btn {
    opacity: 1;
    visibility: visible;
}

.page-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.page-delete-btn svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.a4-page {
    animation: slideIn 0.4s ease-out;
}

.toolbar-btn,
.tool-btn {
    animation: slideIn 0.3s ease-out;
    animation-fill-mode: both;
}

.toolbar-btn:nth-child(1) {
    animation-delay: 0.05s;
}

.toolbar-btn:nth-child(2) {
    animation-delay: 0.1s;
}

.toolbar-btn:nth-child(3) {
    animation-delay: 0.15s;
}

@media (max-width: 1024px) {
    .left-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 200;
        box-shadow: var(--shadow-xl);
    }

    .left-sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .sticky-toolbar {
        padding: 12px 16px;
        overflow-x: auto;
    }

    .editor-container {
        padding: 16px;
    }

    .a4-page {
        width: 100%;
        min-height: auto;
    }

    .editor-instance {
        padding: 16px;
        min-height: auto;
    }
}

@media (max-width: 768px) {
    .sticky-toolbar {
        gap: 6px;
        padding: 8px 12px;
    }

    .toolbar-row {
        gap: 4px;
    }

    .toolbar-group {
        gap: 2px;
    }

    .toolbar-btn {
        width: 32px;
        height: 32px;
    }

    .toolbar-btn svg {
        width: 16px;
        height: 16px;
    }

    .toolbar-divider {
        margin: 0 2px;
        height: 20px;
    }

    .spacing-controls select {
        font-size: 0.75rem;
        padding: 4px 8px;
    }

    .editor-container {
        padding: 12px;
    }

    .page-controls {
        flex-direction: column;
        gap: 12px;
    }

    .page-tabs {
        max-width: 100%;
        justify-content: flex-start;
    }
}

.ck-editor__editable:focus {
    outline: none;
}

.ck-editor__editable.ck-focused {
    border: none !important;
    box-shadow: none !important;
}

.ck-dropdown__panel {
    background: var(--bg-page) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-lg) !important;
}

.ck-list__item {
    border-radius: var(--radius-xs) !important;
}

.ck-list__item:hover {
    background: var(--border-light) !important;
}

.ck-list__item.ck-selected {
    background: var(--primary) !important;
    color: white !important;
}

/* Typography Preset Styles */
.ck-editor__editable.blog {
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.8;
    font-size: 18px;
    color: #333;
}

.ck-editor__editable.blog h1,
.ck-editor__editable.blog h2,
.ck-editor__editable.blog h3 {
    font-family: 'Arial', sans-serif;
    font-weight: 700;
    color: #222;
}

.ck-editor__editable.blog p {
    margin-bottom: 1.5em;
}

.ck-editor__editable.report {
    font-family: 'Arial', 'Helvetica', sans-serif;
    line-height: 1.6;
    font-size: 14px;
    color: #444;
}

.ck-editor__editable.report h1 {
    font-size: 24px;
    border-bottom: 2px solid #ccc;
    padding-bottom: 8px;
}

.ck-editor__editable.letter {
    font-family: 'Times New Roman', serif;
    line-height: 1.5;
    font-size: 16px;
    color: #000;
}

.ck-editor__editable.letter p {
    text-indent: 2em;
}

.ck-editor__editable.modern {
    font-family: 'Helvetica', 'Arial', sans-serif;
    line-height: 1.7;
    font-size: 16px;
    color: #222;
    letter-spacing: 0.3px;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--border-light);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   PRINT BUTTON STYLES
   ============================================ */
.toolbar-btn#printBtn {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

.toolbar-btn#printBtn:hover {
    background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.4);
}

.toolbar-btn#printBtn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(99, 102, 241, 0.3);
}

/* Print button animation */
@keyframes printPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.toolbar-btn#printBtn.printing {
    animation: printPulse 0.5s ease-in-out;
}

/* ============================================
   PREVIEW MODE STYLES
   ============================================ */

/* Preview Container */
.preview-container {
    display: none;
    flex-direction: column;
    height: 100%;
    background: var(--bg-app);
    transition: var(--transition);
}

.preview-container.active {
    display: flex;
}

.preview-header {
    padding: 20px 24px;
    background: var(--bg-toolbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.preview-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.preview-actions {
    display: flex;
    gap: 12px;
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

/* A4 Preview Page */
.preview-page {
    width: 210mm;
    /* A4 width */
    min-height: 297mm;
    /* A4 height */
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 25mm;
    /* Standard A4 margins */
    position: relative;
    page-break-after: always;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.preview-page-header {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 16px;
}

.preview-page-content {
    flex: 1;
    font-family: inherit;
    line-height: 1.6;
    color: var(--text-primary);
    font-size: 14px;
}

.preview-page-content h1 {
    font-size: 24px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.preview-page-content h2 {
    font-size: 20px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.preview-page-content h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.preview-page-content p {
    margin-bottom: 12px;
}

.preview-page-content ul,
.preview-page-content ol {
    margin-left: 24px;
    margin-bottom: 12px;
}

.preview-page-content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 16px;
    margin-left: 0;
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

.preview-page-content table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 12px;
}

.preview-page-content th,
.preview-page-content td {
    border: 1px solid var(--border);
    padding: 8px;
    text-align: left;
}

.preview-page-content th {
    background: var(--border-light);
    font-weight: 600;
}

.preview-placeholder {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 40px;
    opacity: 0.7;
}

/* Print Preview Styles */
@media print {
    body * {
        visibility: hidden;
    }

    .print-preview-content,
    .print-preview-content * {
        visibility: visible;
    }

    .print-preview-content {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    .print-page {
        width: 210mm;
        min-height: 297mm;
        background: white;
        padding: 25mm;
        page-break-after: always;
        font-family: 'Arial', sans-serif;
        line-height: 1.6;
        color: #000;
    }

    .print-page-header {
        font-size: 12px;
        font-weight: 600;
        color: #666;
        text-transform: uppercase;
        padding-bottom: 10px;
        border-bottom: 1px solid #ddd;
        margin-bottom: 15px;
    }

    .print-page-content {
        font-size: 12pt;
    }

    .print-page-content h1 {
        font-size: 18pt;
        margin-bottom: 12pt;
    }

    .print-page-content h2 {
        font-size: 16pt;
        margin-bottom: 10pt;
    }

    .print-page-content h3 {
        font-size: 14pt;
        margin-bottom: 8pt;
    }

    .print-page-content p {
        margin-bottom: 10pt;
    }

    .no-print {
        display: none !important;
    }
}

/* Responsive Preview */
@media (max-width: 1200px) {
    .preview-page {
        width: 100%;
        min-height: auto;
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .preview-header {
        padding: 16px;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .preview-actions {
        justify-content: center;
    }

    .preview-content {
        padding: 16px;
        gap: 24px;
    }

    .preview-page {
        padding: 16px;
    }
}

/* Preview Mode Button States */
.tool-btn.preview-btn.active {
    background: var(--primary);
    color: white;
}

.tool-btn.preview-btn.active:hover {
    background: var(--primary-hover);
}

/* Animation for preview pages */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.preview-page {
    animation: fadeInUp 0.3s ease-out;
}

.preview-page:nth-child(1) {
    animation-delay: 0.05s;
}

.preview-page:nth-child(2) {
    animation-delay: 0.1s;
}

.preview-page:nth-child(3) {
    animation-delay: 0.15s;
}

.preview-page:nth-child(4) {
    animation-delay: 0.2s;
}

.preview-page:nth-child(5) {
    animation-delay: 0.25s;
}

/* Virtual Keyboard Styles */
.virtual-keyboard-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: auto;
    top: auto;
    width: 420px;
    background: #f1f3f4;
    border: 1px solid #dadce0;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    font-family: 'Noto Sans Bengali', 'Segoe UI', sans-serif;
    display: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.virtual-keyboard-container.show {
    display: block;
    animation: keyboardSlideUp 0.2s ease;
}

@keyframes keyboardSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.keyboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dadce0;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.keyboard-header:active {
    cursor: grabbing;
}

.keyboard-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #3c4043;
}

.keyboard-language-icon {
    font-size: 16px;
}

.keyboard-language-name {
    font-family: 'Noto Sans Bengali', sans-serif;
}

.keyboard-close-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #5f6368;
    transition: background-color 0.1s;
}

.keyboard-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Keyboard Control Row */
.keyboard-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #e0e0e0;
}

.keyboard-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.keyboard-row {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 4px;
    margin-bottom: 4px;
    justify-items: stretch;
}

/* Center shorter rows by adjusting grid column start */
.keyboard-row--centered {
    justify-content: center;
}

.keyboard-key {
    height: 38px;
    background: white;
    border: 1px solid #dadce0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    color: #3c4043;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.1s, border-color 0.1s, box-shadow 0.1s;
    font-family: 'Segoe UI', 'Noto Sans Bengali', sans-serif;
    padding: 0;
    min-width: 0;
}

.keyboard-key:hover {
    background-color: #f1f3f4;
    border-color: #1a73e8;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.keyboard-key:active {
    background-color: #e8f0fe;
    transform: translateY(1px);
}

.keyboard-key-space {
    grid-column: span 5;
    font-size: 13px;
    color: #5f6368;
}

.keyboard-key-backspace {
    grid-column: span 2;
    background-color: #f8f9fa;
    color: #1a73e8;
    font-weight: 500;
}

.keyboard-key-enter {
    grid-column: span 2;
    background-color: #f8f9fa;
    color: #1a73e8;
    font-weight: 500;
}

.keyboard-key-caps {
    grid-column: span 2;
    background-color: #f8f9fa;
    color: #1a73e8;
    font-weight: 500;
    font-size: 12px;
}

.keyboard-key-shift {
    grid-column: span 2;
    background-color: #f8f9fa;
    color: #1a73e8;
    font-weight: 500;
    font-size: 12px;
}

.keyboard-key-ctrl {
    grid-column: span 2;
    background-color: #f8f9fa;
    color: #1a73e8;
    font-weight: 500;
    font-size: 12px;
}

.keyboard-key-alt {
    grid-column: span 2;
    background-color: #f8f9fa;
    color: #34a853;
    font-weight: 500;
    font-size: 12px;
}

.keyboard-key-arrow {
    background-color: #f8f9fa;
    color: #5f6368;
    font-weight: 500;
    font-size: 14px;
}

.keyboard-key-backspace:hover,
.keyboard-key-enter:hover,
.keyboard-key-caps:hover,
.keyboard-key-shift:hover,
.keyboard-key-ctrl:hover,
.keyboard-key-alt:hover,
.keyboard-key-arrow:hover {
    background-color: #e8f0fe;
}

.keyboard-key-backspace svg,
.keyboard-key-enter svg {
    stroke-width: 2.5;
}

/* Mode buttons and indicators in control row */
.keyboard-mode-buttons {
    display: flex;
    gap: 8px;
}

.keyboard-mode-btn {
    padding: 6px 12px;
    background: #f1f3f4;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.1s;
    white-space: nowrap;
}

.keyboard-mode-btn:hover {
    background: #e8eaed;
    border-color: #c6dafc;
}

.keyboard-mode-btn.active {
    background: #1a73e8;
    color: white;
    border-color: #1a73e8;
}

.keyboard-mode-indicator {
    font-size: 12px;
    font-weight: 500;
    color: #5f6368;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #dadce0;
}

/* Special key states */
.keyboard-key-shift.active,
.keyboard-key-ctrl.active,
.keyboard-key-caps.active {
    background: #1a73e8;
    color: white;
    border-color: #1a73e8;
}

.keyboard-key-alt.active {
    background: #34a853;
    color: white;
    border-color: #34a853;
}

.keyboard-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1a73e8;
    border: none;
    color: white;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
    z-index: 10001;
    transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.keyboard-toggle-btn:hover {
    background: #0d62d9;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(26, 115, 232, 0.4);
}

.keyboard-toggle-btn:active {
    transform: translateY(0);
}

.keyboard-toggle-btn svg {
    stroke-width: 2.5;
}

/* Dark theme support */
[data-theme="dark"] .virtual-keyboard-container {
    background: #2d2d2d;
    border-color: #444;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .keyboard-title {
    color: #e8eaed;
}

[data-theme="dark"] .keyboard-key {
    background: #3c4043;
    border-color: #5f6368;
    color: #e8eaed;
}

[data-theme="dark"] .keyboard-key:hover {
    background-color: #4a4d50;
    border-color: #8ab4f8;
}

[data-theme="dark"] .keyboard-key-backspace,
[data-theme="dark"] .keyboard-key-enter {
    background-color: #444;
    color: #8ab4f8;
}

[data-theme="dark"] .keyboard-close-btn {
    color: #9aa0a6;
}

[data-theme="dark"] .keyboard-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .virtual-keyboard-container {
        width: 95%;
        right: 2.5%;
        bottom: 10px;
        padding: 6px;
    }

    .keyboard-control-row {
        padding: 4px 0;
        margin-bottom: 6px;
    }

    .keyboard-row {
        grid-template-columns: repeat(12, 1fr);
        gap: 3px;
        margin-bottom: 3px;
    }

    .keyboard-key {
        font-size: 12px;
        height: 30px;
    }

    .keyboard-key-space {
        grid-column: span 3;
    }

    .keyboard-key-backspace,
    .keyboard-key-enter,
    .keyboard-key-caps,
    .keyboard-key-shift,
    .keyboard-key-ctrl,
    .keyboard-key-alt,
    .keyboard-key-arrow {
        grid-column: span 2;
        font-size: 11px;
    }

    .keyboard-mode-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .keyboard-mode-indicator {
        font-size: 11px;
        padding: 3px 6px;
    }

    .keyboard-toggle-btn {
        width: 48px;
        height: 48px;
        bottom: 10px;
        right: 10px;
    }
}

/* Auto Type Panel Styles */
.auto-type-panel {
    position: fixed;
    top: 100px;
    right: 20px;
    width: 320px;
    background: white;
    border: 1px solid #dadce0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100000;
    display: none;
    font-family: 'Segoe UI', sans-serif;
    overflow: hidden;
}

.auto-type-panel.show {
    display: block;
    animation: fadeInUp 0.2s ease;
}

.auto-type-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #dadce0;
}

.auto-type-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #3c4043;
}

.auto-type-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #5f6368;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.auto-type-close:hover {
    background: #e8f0fe;
    color: #1a73e8;
}

.auto-type-body {
    padding: 16px;
}

.auto-type-input {
    width: 100%;
    height: 120px;
    padding: 12px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.auto-type-input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.auto-type-speed {
    margin-bottom: 16px;
}

.auto-type-speed label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #3c4043;
    margin-bottom: 6px;
}

.auto-type-speed select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.auto-type-speed select:focus {
    outline: none;
    border-color: #1a73e8;
}

.auto-type-buttons {
    display: flex;
    gap: 8px;
}

.auto-type-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.insert-btn {
    background: #1a73e8;
    color: white;
}

.insert-btn:hover {
    background: #0d62d9;
}

.typing-btn {
    background: #34a853;
    color: white;
}

.typing-btn:hover {
    background: #2e9749;
}

.cancel-btn {
    background: #f1f3f4;
    color: #3c4043;
}

.cancel-btn:hover {
    background: #e8eaed;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .auto-type-panel {
        width: 280px;
        right: 10px;
        top: 80px;
    }
}