/* Text Formatter Styles */
/* Responsive two-column layout for chat and formatted display */
/* Excluded from Android version via :not(.conversation-fixed-layout) */

/* Main container layout for web version conversation mode */
body.conversation-mode:not(.conversation-fixed-layout) {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two equal columns */
    grid-template-rows: var(--layout-header-height) var(--layout-widget-height) var(--layout-prompt-height) var(--layout-ptt-height) var(--layout-footer-height);
    grid-template-areas:
        "header header"
        "widget formatted"
        "prompt formatted"
        "ptt formatted"
        "footer formatted";
    gap: 0;
    max-width: 100vw;
    overflow: hidden;

    /* Header spans both columns */
    .header {
        grid-area: header;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--layout-header-height);
        z-index: 1000;
    }

    /* Widget area (left column) */
    .widget-area {
        grid-area: widget;
        position: relative;
        height: var(--layout-widget-height);
        overflow: hidden;
    }

    /* Prompt suggestion (left column) */
    #single-prompt-suggestion {
        grid-area: prompt;
        position: relative;
        height: var(--layout-prompt-height);
    }

    /* PTT container (left column) */
    .ptt-container {
        grid-area: ptt;
        position: relative;
        height: var(--layout-ptt-height);
    }

    /* Footer (left column) */
    .footer {
        grid-area: footer;
        position: relative;
        height: var(--layout-footer-height);
        overflow: hidden;
    }
}

/* Formatted display area (right column) - positioned as overlay */
.formatted-display {
    position: fixed;
    top: var(--layout-header-height);
    right: 0;
    width: 50%;
    height: calc(100vh - var(--layout-header-height));
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
    z-index: 500;
    overflow-y: auto;
    padding: 20px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

/* Formatted display header */
.formatted-display .header {
    position: sticky;
    top: 0;
    background: #ffffff;
    padding: 15px 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
    z-index: 501;
}

.formatted-display .header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #374151;
}

/* Message containers in formatted display */
.formatted-message {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}

.formatted-message .original {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

.formatted-message .formatted {
    color: #374151;
    line-height: 1.6;
}

/* Formatted content styling */
.formatted-content {
    line-height: 1.6;
}

.formatted-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.formatted-content li {
    margin-bottom: 5px;
}

.formatted-content p {
    margin-bottom: 10px;
}

.formatted-content p:last-child {
    margin-bottom: 0;
}

.formatted-content strong {
    font-weight: 600;
    color: #111827;
}

.formatted-content em {
    font-style: italic;
    color: #374151;
}

/* Toggle controls */
.format-toggle {
    position: fixed;
    top: calc(var(--layout-header-height) + 20px);
    right: 20px;
    z-index: 502;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.format-toggle label {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: #374151;
    cursor: pointer;
}

.format-toggle input {
    margin-right: 8px;
}

/* Global formatting toggle */
.global-format-toggle {
    position: fixed;
    top: calc(var(--layout-header-height) + 60px);
    right: 20px;
    z-index: 502;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s ease;
}

.global-format-toggle:hover {
    background: #3730a3;
}

.global-format-toggle.active {
    background: #10b981;
}

.global-format-toggle.active:hover {
    background: #059669;
}

/* Loading states */
.formatting-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    border-top-color: #4f46e5;
    animation: spin 1s ease-in-out infinite;
}

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

/* Mobile responsive adjustments */
@media (max-width: 1024px) {
    body.conversation-mode:not(.conversation-fixed-layout) {
        display: block;
        grid-template-columns: none;
        grid-template-rows: none;
        grid-template-areas: none;
    }

    .formatted-display {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        height: auto;
        max-width: 50vw;
        margin: 20px auto;
        border-left: none;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
    }

    .format-toggle,
    .global-format-toggle {
        position: relative;
        top: auto;
        right: auto;
        margin: 10px 0;
    }
}

@media (max-width: 768px) {
    body.conversation-mode:not(.conversation-fixed-layout) {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "widget"
            "formatted"
            "prompt"
            "ptt"
            "footer";
    }

    .formatted-display {
        max-width: 90vw;
        padding: 15px;
    }
}