/* **************************************************************************
   UWS Words - UI/UX Styling
   Modern, Flat Design with Pageless Editor Canvas
   ************************************************************************** */

:root {
    /* Color Palette - Modern Docs Style */
    --primary-blue: #0b57d0;
    --primary-blue-hover: #0842a0;
    --primary-blue-light: rgba(11, 87, 208, 0.1);
    --bg-app: #f4f5f7;
    --bg-paper: #ffffff;
    --bg-toolbar: #f0f4f9;
    --bg-hover: #e8eaed;
    --border-soft: #c7c7c7;
    --border-light: #e0e0e0;
    --text-primary: #1f1f1f;
    --text-secondary: #5f6368;
    --text-placeholder: #9aa0a6;
    --success-green: #0f9d58;
}

/* Base Reset & Typography */
body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-app);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* **************************************************************************
   1. Top Navigation Bar
   ************************************************************************** */
#top-bar {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-light);
    height: 64px;
    box-sizing: border-box;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.logo-icon {
    font-size: 42px !important;
    color: var(--primary-blue);
}

.title-section {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0; /* Ensures truncation works on narrow screens */
}

/* Document Title - Interactive Feedback */
#doc-title {
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    border: 1px solid transparent;
    padding: 4px 8px;
    margin-left: -8px;
    border-radius: 4px;
    width: fit-content;
    outline: none;
    background: transparent;
    transition: all 0.2s ease-in-out;
}

#doc-title:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-light);
}

#doc-title:focus {
    background-color: #ffffff;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px var(--primary-blue-light);
}

.doc-actions {
    display: flex;
    gap: 4px;
    margin-top: 2px;
    margin-left: -8px;
}

.nav-item {
    font-size: 13.5px;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Action Section */
.action-section {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0; /* Prevents buttons from being squished */
}

.save-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    user-select: none;
}

.sync-icon {
    font-size: 18px !important;
}

.action-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Primary Button with Glass/Modern touch */
.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--primary-blue);
    color: #ffffff;
    border: none;
    padding: 8px 24px;
    border-radius: 24px; /* Pill shape */
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

.btn-primary:hover {
    background-color: var(--primary-blue-hover);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary .material-symbols-outlined {
    font-size: 18px !important;
}

/* Secondary Button */
.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-soft);
    padding: 8px 20px;
    border-radius: 24px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-light);
}

.btn-secondary .material-symbols-outlined {
    font-size: 18px !important;
    color: var(--text-secondary);
}

.avatar {
    width: 36px;
    height: 36px;
    background-color: #8ab4f8;
    color: #174ea6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border 0.2s;
}

.avatar:hover {
    border: 2px solid var(--primary-blue);
}

/* **************************************************************************
   2. Formatting Toolbar
   ************************************************************************** */
#toolbar {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    background-color: var(--bg-toolbar);
    border-radius: 24px; /* Floating pill look */
    margin: 8px 16px 0 16px;
    flex-wrap: wrap;
    gap: 8px;
}

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

.divider {
    width: 1px;
    height: 20px;
    background-color: var(--border-soft);
    margin: 0 4px;
}

.tool-btn {
    background: transparent;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #444746;
    transition: background-color 0.2s;
}

.tool-btn:hover {
    background-color: #dfe3eb;
}

.tool-btn .material-symbols-outlined {
    font-size: 20px !important;
}

.tool-select {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    border: 1px solid transparent;
    background-color: transparent;
    padding: 6px 8px;
    border-radius: 4px;
    color: #444746;
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s;
}

.tool-select:hover {
    background-color: #dfe3eb;
}

.tool-select.small {
    width: 60px;
}

/* **************************************************************************
   3. Editor Canvas Area (Pageless Mode)
   ************************************************************************** */
#canvas-wrapper {
    flex: 1;
    overflow-y: auto;
    background-color: var(--bg-paper);
    display: flex;
    justify-content: center;
    padding: 0;
    scrollbar-width: thin;
}

#editor {
    /* Full-width edge-to-edge layout */
    width: 100%; 
    min-height: calc(100vh - 120px); 
    background-color: var(--bg-paper);
    box-shadow: none;
    padding: 40px;
    box-sizing: border-box;
    outline: none;
    /* Default typed font */
    font-family: 'Arial', sans-serif; 
    font-size: 12pt;
    line-height: 1.6;
    color: #000000;
    cursor: text;
}

/* Empty Document Placeholder Styling */
#editor[data-placeholder]:empty:before {
    content: attr(data-placeholder);
    color: var(--text-placeholder);
    pointer-events: none;
    display: block;
    font-style: italic;
}

/* Selection Color */
::selection {
    background-color: var(--primary-blue-light);
}

/* **************************************************************************
   4. Bottom Status Bar
   ************************************************************************** */
#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background-color: #ffffff;
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-secondary);
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

.status-icon {
    font-size: 16px !important;
    color: var(--text-secondary);
}

/* Sleek Animation for WASM Engine Status */
@keyframes engine-pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; color: var(--success-green); }
    100% { opacity: 0.6; }
}

.wasm-icon {
    font-size: 18px !important;
    animation: engine-pulse 2.5s infinite ease-in-out;
}

/* **************************************************************************
   5. Mobile Responsiveness Optimization
   ************************************************************************** */
@media screen and (max-width: 850px) {
    #canvas-wrapper {
        padding: 0; 
        background-color: var(--bg-paper);
    }

    #editor {
        width: 100%;
        min-height: calc(100vh - 120px); 
        padding: 24px 16px; 
        font-size: 14pt; 
        box-shadow: none; 
        border: none;
        border-top: 1px solid var(--border-light);
        margin: 0;
    }

    #top-bar {
        padding: 8px 12px;
        gap: 8px;
    }

    .doc-actions { display: none; }

    .title-section {
        flex-grow: 1;
        overflow: hidden;
    }

    #doc-title {
        font-size: 16px;
        width: 100%;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
    }

    .action-section { gap: 6px; }

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

    .save-status .status-text { display: none; }

    .btn-primary, .btn-secondary {
        font-size: 0; 
        width: 32px;
        height: 32px;
        padding: 0;
        border-radius: 50%; 
        justify-content: center;
        gap: 0;
    }

    .btn-primary .material-symbols-outlined, 
    .btn-secondary .material-symbols-outlined {
        font-size: 18px !important;
        margin: 0;
    }

    .avatar { display: none; }

    #toolbar {
        margin: 0;
        border-radius: 0;
        padding: 6px 12px;
        border-bottom: 1px solid var(--border-light);
        background-color: #ffffff;
        gap: 6px;
        flex-wrap: wrap; 
    }

    .divider { display: none; }
    .toolbar-group { gap: 2px; }
    .tool-btn { width: 28px; height: 28px; }
    .tool-btn .material-symbols-outlined { font-size: 18px !important; }
    .tool-select { padding: 4px 6px; font-size: 13px; }
    .tool-select.small { width: 48px; }

    #status-bar { padding: 6px 12px; }
    .status-right { display: none; }
    .status-left {
        width: 100%;
        justify-content: center; 
        gap: 16px;
    }
}

/* **************************************************************************
   6. Document List Modal (Glassmorphism & Modern UI)
   ************************************************************************** */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.45); /* Deep slate overlay for contrast */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-paper);
    width: 90%;
    max-width: 540px;
    max-height: 85vh;
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    transform: translateY(24px) scale(0.97);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Smooth spring bounce */
    overflow: hidden;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 2;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* Close Icon Button */
.icon-btn {
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    transform: rotate(90deg); /* Playful micro-interaction */
}

.icon-btn .material-symbols-outlined {
    font-size: 22px !important;
}

/* Modal Body */
.modal-body {
    padding: 8px 0;
    overflow-y: auto;
    scrollbar-width: thin;
    flex-grow: 1;
    position: relative;
}

/* Custom Webkit Scrollbar for Modal */
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
    background-color: var(--border-soft);
    border-radius: 10px;
}

/* Document List Items */
.doc-list-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    gap: 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    background-color: transparent;
    transition: background-color 0.2s ease, padding-left 0.2s ease;
}

.doc-list-item:last-child {
    border-bottom: none;
}

.doc-list-item:hover {
    background-color: var(--bg-toolbar); /* Softer hover color */
    padding-left: 28px; /* Elegant indent interaction */
}

/* Item Icon */
.doc-list-item .doc-icon {
    font-size: 28px !important;
    color: var(--primary-blue);
    opacity: 0.85;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.doc-list-item:hover .doc-icon {
    transform: scale(1.1);
    opacity: 1;
}

/* Item Content Info */
.doc-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
    min-width: 0; /* Critical for flexbox text truncation */
}

.doc-title-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.doc-meta-text {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
```