:root {
    --primary: #ef4444;
    /* Red as requested */
    --primary-dark: #b91c1c;
    --secondary: #64748b;
    --light: #f8fafc;
    --dark: #0f172a;
    --white: #ffffff;
    --border: #e2e8f0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--light);
    color: var(--dark);
    margin: 0;
    line-height: 1.6;
    letter-spacing: -0.01em;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
header {
    background: var(--white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 50;
}

.nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: bold;
    font-size: 1.25rem;
    color: var(--primary);
}

.brand img {
    height: 40px;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-extra {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-extra .mobile-btn {
    display: none;
}

.site-share-btn, .add-fav-btn {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    margin: 0 0.25rem;
}
.site-share-btn:hover, .add-fav-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}
.site-share-btn i, .add-fav-btn i {
    color: var(--primary);
    font-size: 1rem;
}
.add-fav-btn i {
    color: #f59e0b;
}
@media (max-width: 768px) {
    .nav-btn-text, .add-fav-btn {
        display: none !important;
    }
}

.nav-links a {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    color: var(--secondary);
    transition: all 0.2s ease;
}

.nav-links a:hover {
    color: var(--dark);
    background: #f8fafc;
}

.nav-links a.active {
    color: #9f1239;
    /* Darker red for contrast */
    background: #ffe4e6;
    /* Light pink background */
    font-weight: 600;
}

/* User Dropdown */
.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: var(--secondary);
    transition: all 0.2s ease;
    font-size: 1rem;
}

.user-dropdown-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.user-dropdown-toggle .dropdown-arrow {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}

.user-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
    overflow: hidden;
}

.user-dropdown:hover .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--dark);
    transition: all 0.15s ease;
}

.user-dropdown-menu a:hover {
    background: var(--light);
    color: var(--primary);
}

.user-dropdown-menu a i {
    width: 16px;
    text-align: center;
    color: var(--secondary);
}

.user-dropdown-menu a:hover i {
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

/* Language Select */
.lang-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    color: var(--secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-select:hover,
.lang-select:focus {
    border-color: var(--primary);
    color: var(--primary);
    outline: none;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Navigation actions removed site-share-btn from here to .nav-extra */

.site-share-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.site-share-btn i {
    color: var(--primary);
    font-size: 1rem;
}

@media (max-width: 768px) {
    .site-share-btn span {
        display: none;
    }

    .site-share-btn {
        padding: 0.5rem;
        border-radius: 50%;
        width: 36px;
        height: 36px;
        justify-content: center;
        margin: 0 0.25rem;
    }
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-outline {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Mobile */
.mobile-check {
    display: none;
}

@media (max-width: 768px) {
    .nav-extra .mobile-btn {
        display: block;
    }
}

@media (max-width: 768px) {
    .nav-extra {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 70px;
        left: auto;
        right: 0;
        width: auto;
        min-width: 150px;
        max-width: 90vw;
        background: white;
        flex-direction: column;
        padding: 1rem 0.5rem;
        box-shadow: -4px 4px 10px rgba(0, 0, 0, 0.1);
        border-bottom-left-radius: 12px;
        border-left: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
    }

    .nav-links a {
        white-space: nowrap;
        text-align: center;
        width: 100%;
        box-sizing: border-box;
    }

    .mobile-check:checked~.nav-links {
        display: flex;
    }

    .nav-extra .mobile-btn {
        display: block;
        padding: 0.5rem;
        cursor: pointer;
        font-size: 1.5rem;
        margin-right: -0.5rem;
        /* Offset padding for alignment */
    }

    .nav-extra .site-share-btn {
        margin: 0;
    }

    .mobile-check:checked~.nav-extra .mobile-btn .fa-bars:before {
        content: "\f00d";
    }

    #mobile-file-share {
        display: inline-flex !important;
    }

    #download-original {
        display: none !important;
    }
}

/* Footer */
footer {
    background: #1f2937;
    color: #9ca3af;
    padding: 3rem 0;
    margin-top: 4rem;
    text-align: center;
}

/* Util */
.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 1rem;
}

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    border: 1px solid var(--border);
}

/* Admin Utilities */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background: #f8fafc;
}

.fw-bold {
    font-weight: 600;
}

.text-muted {
    color: var(--secondary);
}

.text-xs {
    font-size: 0.75rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
}

.bg-success {
    background: #dcfce7;
    color: #166534;
}

.bg-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.btn-outline-danger {
    background: white;
    border: 1px solid #fee2e2;
    color: #b91c1c;
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.btn-outline-danger:hover {
    background: #fee2e2;
    border-color: #b91c1c;
}

.btn-outline-success {
    background: white;
    border: 1px solid #dcfce7;
    color: #166534;
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.btn-outline-success:hover {
    background: #dcfce7;
    border-color: #166534;
}

/* Shared Custom Modal Backdrop */
.custom-modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.custom-modal-backdrop.show {
    display: flex;
    opacity: 1;
}

/* Sample Modal Styles (Shared across index, demo, local_editor) */
.sample-modal-content {
    width: 90vw !important;
    max-width: 1200px !important;
    height: 90vh !important;
    padding: 0;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    background: white;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.sample-modal-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    min-width: 320px;
}

.sample-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #1e293b;
    font-weight: 700;
    white-space: nowrap;
}

.close-sample-modal,
.close-tmpl-preview-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    transition: color 0.2s;
}

.close-sample-modal:hover,
.close-tmpl-preview-modal:hover {
    color: #ef4444;
}

.sample-modal-body {
    background: #f1f5f9;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    overflow: hidden;
    flex: 1 1 auto;
}

.sample-preview-viewport {
    width: 100%;
    flex-grow: 1;
    /* allow it to grow to fill modal body */
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    /* Dimensions are set dynamically by JS based on screen size */
    margin: 0 auto;
    /* Dimensions are set dynamically by JS based on screen size */
}

#docx-container,
#tmpl-preview-container {
    width: 800px;
    margin: 0 auto;
    /* Native width for standard render */
    transform-origin: top center;
}

/* Ensure docx-preview wrappers fill container correctly */
#docx-container .docx-wrapper,
#tmpl-preview-container .docx-wrapper {
    background: transparent !important;
    padding: 1rem !important;
}

#docx-container .docx-wrapper>section.docx,
#tmpl-preview-container .docx-wrapper>section.docx {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    padding: 2rem !important;
    margin: 0 auto !important;
}

.sample-loading {
    padding: 6rem 2rem;
    text-align: center;
    color: #64748b;
}

.sample-modal-footer {
    padding: 1rem 1.5rem;
    background: white;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: center;
}

.sample-modal-footer .hero-btn-primary {
    text-decoration: none;
    width: fit-content !important;
    display: none;
    padding: 0.6rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1;
    border: none;
    cursor: pointer;
}

@media (max-width: 768px) {
    .sample-modal-content {
        max-width: 96vw;
        max-height: 90vh;
    }

    .sample-modal-body {
        padding: 0.5rem;
        justify-content: flex-start;
    }

    .sample-preview-viewport {
        width: 100%;
        height: auto;
        overflow-x: auto !important;
        padding: 0 !important;
    }

    #docx-container .docx-wrapper,
    #tmpl-preview-container .docx-wrapper {
        padding: 0 !important;
    }

    #docx-container .docx-wrapper>section.docx,
    #tmpl-preview-container .docx-wrapper>section.docx {
        padding: 0.5rem !important;
    }

    #tmpl-preview-container,
    #docx-container {
        margin: 0;
        transform-origin: top left;
        padding-bottom: 2rem;
    }

    .sample-modal-header {
        padding: 0.8rem 1.2rem;
        min-width: 280px;
    }

    .sample-modal-footer {
        padding: 0.8rem 1.2rem;
    }

    .sample-modal-footer .hero-btn-primary {
        padding: 0.5rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* Pagination Styles */
.pagination-container {
    display: none;
    padding: 1rem 1.5rem;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--secondary);
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    gap: 0.25rem;
}

.page-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    background: white;
    color: var(--secondary);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

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

/* PPTX Preview Styles */
#pptx-vue-container,
#tmpl-pptx-vue-container {
    background: #1e293b;
    /* Dark slate background like PPT apps */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-sizing: border-box;
    border-radius: 12px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.vue-office-pptx-canvas-wrapper {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    background: white;
}

#tmpl-preview-container.pptx-mode,
#docx-container.pptx-mode {
    width: 100% !important;
    max-width: 1100px !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

/* Sidebar Toggle System */
.demo-wrapper {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: calc(100vh - 70px);
    transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    /* For absolute toggle button */
}

.demo-wrapper.sidebar-collapsed {
    grid-template-columns: 0 1fr;
}

.sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    visibility: visible;
    position: relative;
    /* For absolute toggle button */
}

.sidebar-collapsed .sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    opacity: 0;
    visibility: hidden;
    border-right: none;
}

.workspace {
    background: #f8fafc;
    padding: 2rem;
    overflow-y: auto;
    transition: padding 0.4s ease;
    min-width: 0;
}

.sidebar-collapsed .workspace {
    padding: 2rem 2rem;
}

.sidebar-toggle-btn {
    position: absolute;
    top: 1.25rem;
    left: 273px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--secondary);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapsed .sidebar-toggle-btn {
    left: 0;
    top: 10px;
    border-radius: 0 0 8px 0;
    border-left: none;
    border-top: none;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.05);
}

.sidebar-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #fef2f2;
}

.sidebar-toggle-btn i {
    font-size: 0.9rem;
    transition: transform 0.4s ease;
}

.sidebar-collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.header-title-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.header-text-content h4 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
}

@media (max-width: 1200px) {
    .demo-wrapper {
        grid-template-columns: 280px 1fr;
    }

    .sidebar-toggle-btn {
        left: 233px;
        /* 280px width - padding/width adjustment */
    }
}

@media (max-width: 768px) {
    .demo-wrapper {
        display: block;
        min-height: auto;
        margin-top: 0;
    }

    .sidebar {
        width: 100% !important;
        border-right: none;
        border-bottom: 1px solid var(--border);
        visibility: visible !important;
        opacity: 1 !important;
        padding: 1.5rem !important;
        margin-top: 0 !important;
    }

    .sidebar-toggle-btn {
        display: none !important;
    }

    .workspace {
        padding: 1rem 0 !important;
    }

    .table-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1.25rem !important;
    }

    .header-main-actions {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        margin-left: 0 !important;
    }

    .header-main-actions .btn-with-help,
    .header-main-actions .btn-text-outline {
        width: 100% !important;
        justify-content: center !important;
    }
}