/* ═══════════════════════════════════════════════════════════════
   UNIVERSAL DOCUMENT STUDIO — Design System
   MS Word 365 + iLovePDF Aesthetic (Clean, Professional, SaaS)
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Core Office Colors */
    --word-blue: #2b579a;
    --word-blue-dark: #1e3c6b;
    --word-blue-light: #eff6fc;
    --pdf-red: #e53935;

    /* Backgrounds */
    --bg-page: #f3f2f1;
    --bg-white: #ffffff;
    --bg-ribbon: #f3f2f1;
    --bg-toolbar: #ffffff;

    /* Text */
    --text-main: #323130;
    --text-muted: #605e5c;
    --text-light: #ffffff;

    /* Borders & Shadows */
    --border-light: #e1dfdd;
    --border-focus: #2b579a;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
    --shadow-page: 0 0 10px rgba(0, 0, 0, 0.15);

    /* Typography */
    --font-sans: 'Inter', 'Segoe UI', system-ui, sans-serif;

    /* UI Dimensions */
    --header-height: 48px;
    --ribbon-height: 100px;
    --status-height: 32px;
}

/* ── Global Reset ──────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    /* App-like behavior, scrolling handled inside */
}

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
}

/* ── App Header (Top Blue Bar) ─────────────────────────── */
.app-header {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.top-app-bar {
    height: var(--header-height);
    background: var(--word-blue);
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: var(--text-light);
    gap: 16px;
    transition: background 0.3s ease;
}

/* PDF Mode Color Switch */
.pdf-mode .top-app-bar {
    background: var(--pdf-red);
}

.app-launcher {
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    display: flex;
}

.app-launcher:hover {
    background: rgba(255, 255, 255, 0.1);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
}

.word-icon {
    background: white;
    color: var(--word-blue);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 14px;
}

.pdf-mode .word-icon {
    color: var(--pdf-red);
    content: "P";
}

.mode-switcher {
    display: flex;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 2px;
    margin-left: 20px;
}

.mode-btn {
    background: transparent;
    border: none;
    color: white;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.2s;
}

.mode-btn.active {
    background: white;
    color: var(--word-blue);
    opacity: 1;
    box-shadow: var(--shadow-sm);
}

.pdf-mode .mode-btn.active {
    color: var(--pdf-red);
}

.search-bar-container {
    flex: 1;
    display: flex;
    justify-content: center;
}

.search-bar {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    width: 100%;
    max-width: 400px;
    color: var(--text-muted);
}

.search-bar input {
    border: none;
    background: transparent;
    padding: 8px;
    width: 100%;
    outline: none;
    font-size: 14px;
    color: var(--text-main);
}

.search-bar:focus-within {
    background: white;
}

.top-right-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Credits Badge */
.credits-badge {
    background: rgba(255, 185, 0, 0.2);
    color: #ffd700;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid rgba(255, 185, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 0 10px rgba(255, 185, 0, 0.1);
}

/* Founder Badge */
.founder-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: white;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 12px;
    border-radius: 20px;
    transition: all 0.2s;
    margin-right: 10px;
}

.founder-badge:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.founder-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.founder-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

.founder-title {
    font-size: 10px;
    opacity: 0.8;
    line-height: 1.2;
}

.founder-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.auth-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
}

.auth-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ── Ribbon Container (MS Word) ────────────────────────── */
.ribbon-container {
    background: var(--bg-ribbon);
    border-bottom: 1px solid var(--border-light);
    display: block;
    /* Hidden via JS in PDF mode */
}

.ribbon-container.hidden {
    display: none;
}

.ribbon-tabs {
    display: flex;
    padding: 4px 12px 0;
    gap: 2px;
}

.ribbon-tab {
    background: transparent;
    border: none;
    padding: 6px 16px;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    position: relative;
    outline: none;
}

.ribbon-tab:hover {
    background: rgba(0, 0, 0, 0.05);
}

.ribbon-tab.active {
    background: var(--bg-white);
    color: var(--word-blue);
    font-weight: 600;
}

.ribbon-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--bg-white);
}

.ribbon-tab.ai-tab {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(99, 102, 241, 0.1));
    color: #4f46e5;
    font-weight: 600;
}

.ribbon-tab.ai-tab.active {
    background: white;
    border: 1px solid #e0e7ff;
    border-bottom: none;
}

.ribbon-panel {
    display: none;
    height: var(--ribbon-height);
    background: var(--bg-white);
    padding: 8px 16px 2px;
    align-items: center;
    gap: 16px;
}

.ribbon-panel.active {
    display: flex;
}

.ribbon-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    position: relative;
    padding: 0 8px;
}

.group-label {
    position: absolute;
    bottom: 2px;
    font-size: 11px;
    color: var(--text-muted);
    width: 100%;
    text-align: center;
}

.ribbon-separator {
    width: 1px;
    height: 70%;
    background: var(--border-light);
}

.ribbon-btn-column {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ribbon-btn-column.flex-row {
    flex-direction: row;
    gap: 8px;
}

.ribbon-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--text-main);
    font-size: 12px;
}

.ribbon-btn:hover {
    background: var(--word-blue-light);
    border-color: rgba(43, 87, 154, 0.3);
}

.ribbon-btn.large {
    flex-direction: column;
    padding: 6px 12px;
    gap: 4px;
}

.ribbon-btn.large .icon {
    font-size: 24px;
}

.ribbon-btn.small {
    padding: 4px 8px;
    gap: 6px;
    justify-content: flex-start;
}

.ribbon-btn.small .icon {
    font-size: 14px;
}

/* Font Group */
.font-group,
.paragraph-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.font-dropdowns,
.font-toggles {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ribbon-select {
    border: 1px solid var(--border-light);
    border-radius: 2px;
    padding: 4px;
    font-size: 12px;
    color: var(--text-main);
    font-family: var(--font-sans);
}

.font-family-select {
    width: 130px;
}

.font-size-select {
    width: 45px;
}

.ribbon-btn.toggle {
    width: 24px;
    height: 24px;
    justify-content: center;
    padding: 0;
    font-weight: 600;
}

.ribbon-btn.toggle.italic {
    font-style: italic;
    font-family: serif;
}

.ribbon-btn.toggle.underline {
    text-decoration: underline;
}

.ribbon-btn.toggle.strike {
    text-decoration: line-through;
}

/* Styling overriding Quill toolbar for Ribbon */
.ql-toolbar {
    display: none !important;
}

/* Styles Gallery */
.styles-gallery {
    display: flex;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    height: 60px;
}

.style-item {
    padding: 4px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-right: 1px solid var(--border-light);
    cursor: pointer;
    background: white;
}

.style-item:hover {
    background: var(--word-blue-light);
}

.style-item.active {
    border: 1px solid var(--word-blue);
}

.style-item span {
    font-size: 13px;
}

.style-item small {
    font-size: 10px;
    color: var(--text-muted);
}

/* ── Main Workspace ────────────────────────────────────── */
.main-workspace {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-page);
}

.workspace-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    flex-direction: column;
}

.workspace-view.active {
    display: flex;
}

/* ── Word Editor Container ── */
.editor-canvas-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.document-page {
    background: var(--bg-white);
    width: 21cm;
    /* A4 Width */
    min-height: 29.7cm;
    /* A4 Height */
    box-shadow: var(--shadow-page);
    padding: 96px;
    /* Approx 1 inch margin */
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
}

.quill-editor-area {
    flex: 1;
    font-family: 'Calibri', 'Arial', sans-serif;
    font-size: 11pt;
    line-height: 1.5;
    color: #000;
    border: none;
    outline: none;
}

.ql-container.ql-snow {
    border: none;
    font-family: inherit;
    font-size: inherit;
}

.ql-editor {
    padding: 0;
    min-height: 500px;
    overflow: visible;
}

.ql-editor.ql-blank::before {
    left: 0;
    font-style: normal;
    color: #a0a0a0;
}


.word-status-bar {
    height: var(--status-height);
    background: var(--word-blue-light);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    font-size: 12px;
    color: var(--text-muted);
}

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

.zoom-slider {
    width: 100px;
    accent-color: var(--word-blue);
}

/* ── PDF Tools Dashboard (iLovePDF Clone) ── */
#pdfWorkspace {
    background: #f8f9fa;
    overflow-y: auto;
}

.pdf-hero {
    text-align: center;
    padding: 60px 20px 40px;
    max-width: 800px;
    margin: 0 auto;
}

.pdf-hero h1 {
    font-size: 42px;
    font-weight: 800;
    color: #333;
    margin-bottom: 16px;
}

.pdf-hero p {
    font-size: 18px;
    color: #666;
    line-height: 1.6;
}

.pdf-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    padding: 0 40px 80px;
    max-width: 1400px;
    margin: 0 auto;
}

.pdf-card {
    background: white;
    border-radius: 8px;
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-light);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    top: 0;
}

.pdf-card:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    top: -5px;
    border-color: rgba(229, 57, 53, 0.3);
}

.card-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 800;
    color: white;
    border-radius: 12px;
}

.merge-icon {
    background: var(--pdf-red);
}

.split-icon {
    background: #ff9800;
}

.compress-icon {
    background: #4caf50;
}

.word-icon {
    background: #1976d2;
}

.ppt-icon {
    background: #f44336;
}

.excel-icon {
    background: #43a047;
}

.convert-icon {
    background: #607d8b;
}

.card-icon svg {
    width: 36px;
    height: 36px;
}

.pdf-card h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: #333;
    font-weight: 700;
}

.pdf-card p {
    font-size: 14px;
    color: #777;
    line-height: 1.5;
}

/* ── Utilities ── */
.hidden {
    display: none !important;
}

/* ── Legacy Auth Modal (Kept minimal for functionality) ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-card {
    background: white;
    padding: 32px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    color: var(--text-main);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    font-weight: 700;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}

.tab-group {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-light);
}

.tab {
    background: none;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    position: relative;
}

.tab.active {
    color: var(--word-blue);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--word-blue);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
}

.form-group input {
    padding: 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    outline: none;
}

.form-group input:focus {
    border-color: var(--word-blue);
}

.btn {
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 14px;
}

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

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

.btn-full {
    width: 100%;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}