/**
 * RE::DACT Layout Styles
 * 
 * This file contains:
 * - Header styles
 * - Layout container (content-wrapper)
 * - Main content area
 * - Split view columns
 */

/* --- HEADER --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
    padding: 0 24px;
    background: var(--color-bg-primary);
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
    width: 100%;
    position: relative;
    z-index: 1100;
}

/* Shimmer keyframes - used by toolbar trigger */
@keyframes ui-shimmer {
    0% { left: -100%; }
    30% { left: 150%; }
    100% { left: 150%; }
}

.app-logo {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    color: var(--color-accent) !important;
    opacity: 1 !important;
    z-index: 1200;
}

.logo-hamburger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 18px;
    flex-shrink: 0;
}

.logo-hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--color-accent) !important;
    transition: all var(--transition-fast);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0;
}

.header-actions > button {
    flex-shrink: 0;
}

/* Archive icon 1px lower */
.header-actions .header-icon-btn[title="Archive"] svg {
    transform: translateY(1px);
}

/* --- LAYOUT CONTAINER --- */
.content-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* --- MAIN CONTENT --- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.split {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.column {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-primary);
    overflow: hidden;
    min-width: 0;
}

/* --- GRADIENT VIEW SWITCHER (Mobile) --- */
.view-gradient-switcher {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    cursor: pointer;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
}

.view-right {
    right: 0;
    background: linear-gradient(to left, rgba(var(--color-overlay-dark), 0.1), transparent);
    justify-content: flex-end;
    padding-right: 10px;
}

.view-left {
    left: 0;
    background: linear-gradient(to right, rgba(var(--color-overlay-dark), 0.1), transparent);
    justify-content: flex-start;
    padding-left: 10px;
}

.view-gradient-switcher::after {
    content: '';
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(0,0,0,0.3)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    transition: all 0.3s ease;
}

.view-left::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(0,0,0,0.3)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'%3E%3C/polyline%3E%3C/svg%3E");
}

.view-gradient-switcher:hover::after {
    stroke: rgba(0,0,0,0.6);
    transform: translateX(2px);
}

.view-left:hover::after {
    transform: translateX(-2px);
}

/* --- TOAST NOTIFICATIONS --- */
#toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: #1A1A1A;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 8px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   UNIFIED LAYOUT (50/50 Split)
   ============================================ */

.unified-layout {
    display: flex;
}

/* LEFT COLUMN: Editor only (full height) */
.column-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-primary);
    overflow: hidden;
    min-width: 0;
}

.column-editor .editor {
    flex: 1;
    overflow-y: auto;
}

/* RIGHT COLUMN: Notatnik + Mode Switcher + Chat */
.column-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-primary);
    overflow: hidden;
    min-width: 0;
    border-left: 1px solid var(--color-border-light);
}

/* COLUMN DIVIDER (resizable) */
.column-divider {
    width: 6px;
    background: var(--color-border-light);
    cursor: ew-resize;
    flex-shrink: 0;
    position: relative;
    transition: background 0.15s ease;
}

.column-divider:hover,
.column-divider.dragging {
    background: var(--color-border-medium, #ccc);
}

.column-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 30px;
    background: rgba(var(--color-overlay-dark), 0.2);
    border-radius: 1px;
}

.column-divider:hover::after,
.column-divider.dragging::after {
    background: rgba(var(--color-overlay-dark), 0.3);
}

/* Notatnik Section (resizable, default ~50% of right column) */
.notatnik-section {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 100px;
}

.notatnik-section .editor {
    flex: 1;
    overflow-y: auto;
}

/* ============================================
   MODE SWITCHER ROW
   ============================================ */

.mode-switcher-row {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    background: var(--color-bg-paper-main);
    border-top: 1px solid var(--color-border-light);
    border-bottom: 1px solid var(--color-border-light);
    justify-content: flex-start;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    cursor: ns-resize;
    user-select: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;  /* Firefox */
    -ms-overflow-style: none;  /* IE/Edge */
}

.mode-switcher-row::-webkit-scrollbar {
    display: none;  /* Chrome/Safari */
}

.mode-btn {
    position: relative;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
    border: 1px solid var(--color-border-light);
    color: var(--color-text-secondary, #666);
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    min-width: 80px;
    text-align: center;
}

.mode-btn:hover {
    background: var(--color-bg-hover, #eee);
    border-color: var(--color-border-medium, #ccc);
}

.mode-btn.active {
    background: var(--color-accent);
    color: var(--color-accent-text);
    border-color: var(--color-accent);
    box-shadow: 0 2px 4px rgba(var(--color-overlay-dark), 0.2);
}

.mode-btn.active svg {
    stroke: var(--color-accent-text);
}

.mode-btn.active:hover {
    background: var(--color-accent-hover);
}

.mode-btn-text {
    display: inline;
}

/* Mode Badge (notification count) */
.mode-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 99px;
    background: #DC2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

/* ============================================
   UNIFIED CHAT AREA
   ============================================ */

.unified-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 150px;
    overflow: hidden;
    background: var(--color-bg-paper-main);
}

/* Chat Mode Layers (persistent, all in DOM) */
.chat-mode-layer {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.chat-mode-layer.active {
    display: flex;
}

.chat-mode-layer .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--color-bg-paper-main);
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.04);
}

/* Scroll anchor for auto-scroll */
.chat-mode-layer .scroll-anchor {
    height: 0;
    margin-top: auto;
}

/* Unified Chat Input */
.unified-chat-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: var(--color-bg-paper-main);
    border-top: 1px solid var(--color-border-light);
    align-items: flex-end;
}

.unified-chat-input textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
    resize: none;
    min-height: 40px;
    max-height: 200px;
    line-height: 1.4;
    font-family: inherit;
    overflow-y: auto;
}

.unified-chat-input textarea:focus {
    border-color: var(--color-primary, #000);
}

.unified-chat-input textarea::placeholder {
    color: var(--color-text-tertiary, #999);
}

/* Send Up Button */
.send-up-btn {
    width: var(--btn-height-icon);
    height: var(--btn-height-icon);
    border-radius: 8px;
    border: 1px solid var(--color-border-light);
    background: var(--color-bg-secondary, #f8f8f8);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.send-up-btn:hover {
    background: var(--color-bg-hover, #eee);
    border-color: var(--color-border-medium, #ccc);
}

.send-up-btn:active {
    transform: scale(0.95);
}

/* Send Button */
.send-btn {
    width: var(--btn-height-icon);
    height: var(--btn-height-icon);
    border-radius: 8px;
    border: none;
    background: var(--color-accent);
    color: var(--color-accent-text);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.send-btn:hover {
    background: var(--color-accent-hover);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn .sun-icon {
    display: block;
}

@keyframes sun-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.send-btn .sun-icon.spinning {
    animation: sun-spin 0.4s ease-in-out;
}

/* ============================================
   CHAT MESSAGE STYLES (for unified chat)
   ============================================ */

.chat-mode-layer .chat-message {
    position: relative;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.chat-mode-layer .chat-message.user {
    background: var(--color-accent);
    color: var(--color-accent-text);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-mode-layer .chat-message.assistant {
    background: var(--color-bg-secondary, #f5f5f5);
    color: var(--color-text-primary, #000);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-mode-layer .chat-message.streaming {
    opacity: 0.9;
}

.chat-mode-layer .chat-message.streaming::after {
    content: '▋';
    animation: blink 1s infinite;
    margin-left: 2px;
}

/* Immediate response from ULTRA before routing */
.chat-mode-layer .chat-message.immediate-response {
    background: linear-gradient(135deg, var(--color-bg-secondary, #f5f5f5) 0%, var(--color-bg-hover, #eee) 100%);
    border-left: 3px solid var(--color-primary, #000);
    font-style: italic;
    opacity: 0.9;
}

/* =============================================================================
   MINI VORTEX LOADING - Animation outside box, floating text
   ============================================================================= */

/* Loading container - column layout for thinking indicator */
.chat-mode-layer .chat-message.loading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 12px 0;
}

/* Header row: vortex + status verb */
.chat-mode-layer .loading-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Mini vortex */
.chat-mode-layer .mini-vortex {
    flex-shrink: 0;
}

/* Status text (auto-verb) */
.chat-mode-layer .chat-message.loading .loading-text {
    color: var(--color-text-secondary, #888);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 600;
    background: none;
    border: none;
    padding: 0;
    opacity: 0.8;
}

/* Orson commentary inline after verb */
.chat-mode-layer .orson-comment {
    color: var(--color-text-secondary, #888);
    font-size: 12px;
    opacity: 0.6;
    margin-left: 4px;
}

/* Steps list — gray one-line summaries */
.chat-mode-layer .steps-list {
    margin-left: 52px;
    margin-top: 6px;
}

.chat-mode-layer .step-item {
    color: var(--color-text-secondary, #888);
    font-size: 12px;
    opacity: 0.5;
    padding: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}

.chat-mode-layer .step-item::before {
    content: "● ";
    opacity: 0.4;
}

/* Thinking state - pupil pulse */
.chat-mode-layer .loading.thinking .mv-pupil {
    animation: mvPupilPulse 0.4s ease-in-out infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ============================================
   RESPONSIVE: Mobile adjustments
   ============================================ */

@media (max-width: 768px) {
    /* Mobile: stack columns vertically, show one at a time */
    .unified-layout {
        flex-direction: column;
        position: relative;
    }

    /* Hide column divider on mobile */
    .column-divider {
        display: none;
    }

    .column-editor,
    .column-chat-area {
        flex: none;
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        transition: transform 0.3s ease;
    }

    /* Default: show editor, hide chat area */
    .column-editor {
        transform: translateX(0);
        z-index: 1;
    }

    .column-chat-area {
        transform: translateX(100%);
        z-index: 2;
    }

    /* When chat area is active (via JS class) */
    .unified-layout.show-chat .column-editor {
        transform: translateX(-100%);
    }

    .unified-layout.show-chat .column-chat-area {
        transform: translateX(0);
    }

    /* Notatnik takes more space on mobile */
    .notatnik-section {
        flex: 0 0 35%;
        min-height: 80px;
    }

    /* Mode switcher: horizontal scroll with swipe */
    .mode-switcher-row {
        padding: 8px 12px;
        gap: 8px;
        justify-content: flex-start;
        cursor: default;
    }

    .mode-btn {
        padding: 6px 12px;
        font-size: 11px;
        flex-shrink: 0;
    }

    /* Chat area fills remaining space */
    .unified-chat {
        min-height: 120px;
    }

    /* Unified input compact on mobile */
    .unified-chat-input {
        padding: 8px;
        gap: 6px;
    }

    .unified-chat-input input {
        padding: 8px 12px;
        font-size: 14px;
    }

    .send-btn,
    .send-up-btn {
        width: 36px;
        height: 36px;
    }

    /* Show gradient switchers on mobile */
    .view-gradient-switcher {
        display: flex;
    }

    /* Hide right switcher when chat is showing */
    .unified-layout.show-chat .view-right {
        display: none;
    }

    /* Hide left switcher when editor is showing */
    .unified-layout:not(.show-chat) .view-left {
        display: none;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .mode-btn {
        padding: 5px 10px;
        font-size: 10px;
    }

    .notatnik-section {
        flex: 0 0 30%;
    }
}
