/* ======================================== */
/* A.I.U. Studio v3.0 - Focus View Interface */
/* ======================================== */

/* --- Main Container --- */
.studio-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    background: var(--aiu-bg);
}

/* ========================================= */
/* PERSISTENT HEADER (Optimized)            */
/* ========================================= */

.studio-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 30px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--aiu-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    gap: 20px;
}

.studio-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    margin: 0;
    color: #ffffff;
    flex-shrink: 0;
}

.title-icon {
    font-size: 1.5rem;
}

/* --- View Cycler --- */
.view-cycler {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.cycle-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid var(--aiu-primary);
    color: var(--aiu-primary);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cycle-btn:hover:not(:disabled) {
    background: rgba(168, 85, 247, 0.25);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

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

.cycle-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.cycle-arrow {
    font-weight: bold;
}

.view-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--aiu-text-primary);
    min-width: 120px;
    text-align: center;
}

/* ========================================= */
/* FOCUS VIEWS CONTAINER                    */
/* ========================================= */

.focus-views-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.focus-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    overflow-y: auto;
}

.focus-view.active {
    opacity: 1;
    visibility: visible;
}

/* --- Compact View Headers (Icon + Title on one line) --- */
.view-header-compact {
    flex-shrink: 0;
    text-align: center;
    padding: 15px 30px;
    border-bottom: 2px solid var(--aiu-border);
}

.view-header-compact h2 {
    font-size: 1.5rem;
    margin: 0;
    background: linear-gradient(135deg, var(--aiu-primary), #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.view-icon-inline {
    font-size: 1.8rem;
}

/* ========================================= */
/* VIEW 1: CONVERSATION                     */
/* ========================================= */

#conversation-view {
    padding: 0 30px 20px 30px;
    gap: 15px;
}

/* Condensation Meter (moved to conversation view) */
.condensation-meter-container {
    flex-shrink: 0;
    padding: 12px 20px;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 12px;
    border: 1px solid var(--aiu-border);
}

.condensation-meter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.meter-pip {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(148, 163, 184, 0.4);
    background: transparent;
    transition: all 0.4s ease;
}

.meter-pip.filled {
    background: linear-gradient(135deg, var(--aiu-primary-dark), var(--aiu-primary));
    border-color: var(--aiu-primary);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
    animation: pipFill 0.3s ease-out;
}

@keyframes pipFill {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.meter-pip.pulsing {
    animation: pipPulse 1s ease-in-out infinite;
}

@keyframes pipPulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
    }

    50% {
        transform: scale(1.15);
        box-shadow: 0 0 25px rgba(168, 85, 247, 0.9);
    }
}

.meter-label {
    font-size: 0.85rem;
    color: var(--aiu-text-secondary);
    font-weight: 500;
    margin-left: 5px;
}

/* Condensing Indicator (non-intrusive notification) */
.condensing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 15px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(124, 58, 237, 0.15));
    border-radius: 8px;
    border: 1px solid rgba(168, 85, 247, 0.3);
    animation: fadeInSlide 0.3s ease-out;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.condensing-icon-small {
    font-size: 1.2rem;
    animation: gentlePulse 2s ease-in-out infinite;
}

@keyframes gentlePulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.condensing-text-small {
    font-size: 0.85rem;
    color: var(--aiu-primary);
    font-weight: 600;
}

/* Meter glow animation during summarization */
.meter-pip.summarizing {
    animation: meterGlow 1.5s ease-in-out infinite;
}

@keyframes meterGlow {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
    }

    50% {
        box-shadow: 0 0 30px rgba(168, 85, 247, 1), 0 0 40px rgba(168, 85, 247, 0.8);
    }
}

/* Chat History - Maximized */
.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.6);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border: 1px solid rgba(51, 65, 85, 0.5);
}

.chat-bubble {
    padding: 14px 20px;
    border-radius: 16px;
    max-width: 85%;
    line-height: 1.6;
    word-wrap: break-word;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-bubble {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(124, 58, 237, 0.15));
    border: 1px solid rgba(168, 85, 247, 0.3);
    align-self: flex-start;
}

.user-bubble {
    background: linear-gradient(135deg, var(--aiu-primary-dark), var(--aiu-primary));
    color: #ffffff;
    align-self: flex-end;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

/* Core Memory Prompt */
.core-memory-prompt {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.15));
    border: 2px solid var(--aiu-accent);
    border-radius: 12px;
    padding: 20px;
    animation: pulseGlow 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
    }

    50% {
        box-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
    }
}

.memory-prompt-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    text-align: center;
}

.memory-icon {
    font-size: 2.5rem;
}

#core-memory-question {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
}

.memory-buttons {
    display: flex;
    gap: 15px;
}

.memory-buttons .btn {
    min-width: 100px;
}

/* Chat Input */
.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.chat-input-area textarea {
    width: 100%;
    min-height: 100px;
    resize: vertical;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--aiu-border);
    color: var(--aiu-text-primary);
    padding: 15px;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--aiu-primary);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
    background: rgba(15, 23, 42, 0.95);
}

/* ========================================= */
/* VIEW 2: SUMMARY (Centered on Desktop)    */
/* ========================================= */

#summary-view {
    padding: 0 30px 30px 30px;
    position: relative;
}

.summary-content {
    flex-grow: 1;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 16px;
    padding: 40px;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--aiu-text-primary);
    overflow-y: auto;
    /* Center content on desktop */
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.summary-content p {
    margin: 0 0 1em 0;
}

.placeholder-text {
    color: var(--aiu-text-secondary);
    font-style: italic;
}

/* Condensing Overlay */
.condensing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.condensing-animation {
    text-align: center;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.condensing-icon {
    font-size: 5rem;
    display: block;
    margin-bottom: 20px;
    animation: brainPulse 1.5s ease-in-out infinite;
}

@keyframes brainPulse {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.6));
    }

    50% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 40px rgba(168, 85, 247, 0.9));
    }
}

.condensing-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--aiu-primary);
    margin: 0 0 20px 0;
}

.condensing-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(168, 85, 247, 0.2);
    border-top-color: var(--aiu-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* ========================================= */
/* VIEW 3: PREVIEW (with Sticky Footer)     */
/* ========================================= */

#preview-view {
    padding: 0;
    gap: 0;
}

/* Scrollable content wrapper */
.preview-body {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 30px;
}

.preview-content {
    flex-grow: 1;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 16px;
    padding: 25px;
    overflow-y: auto;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    color: #a5f3fc;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.preview-content code {
    color: var(--aiu-text-secondary);
    font-style: italic;
}

/* --- STICKY FOOTER --- */
.finalization-controls {
    flex-shrink: 0;
    padding: 20px 30px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, 1) 30%);
    border-top: 1px solid var(--aiu-border);
}

.finalization-controls .form-group {
    margin-bottom: 15px;
}

.finalization-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.label-icon {
    font-size: 1.2rem;
}

#ai-username {
    width: 100%;
}

.btn-large {
    width: 100%;
    padding: 16px 32px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-icon {
    font-size: 1.3rem;
}

/* ========================================= */
/* MODAL                                    */
/* ========================================= */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.98));
    border: 2px solid var(--aiu-primary);
    border-radius: 20px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 2px solid var(--aiu-border);
}

.modal-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.75rem;
}

.modal-header p {
    margin: 0;
    color: var(--aiu-text-secondary);
    font-size: 0.95rem;
}

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 25px 30px;
}

#final-document-review {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--aiu-border);
    border-radius: 12px;
    padding: 20px;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #a5f3fc;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 2px solid var(--aiu-border);
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.modal-footer .btn-primary {
    flex: 1;
    min-width: 200px;
}

.modal-footer .btn-secondary {
    flex: 0 0 auto;
}

/* ========================================= */
/* UTILITY & RESPONSIVE                     */
/* ========================================= */

.fullscreen-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    background: var(--aiu-bg);
    z-index: 100;
}

.fullscreen-loader p {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Scrollbar Styling */
.chat-history::-webkit-scrollbar,
.summary-content::-webkit-scrollbar,
.preview-content::-webkit-scrollbar,
#final-document-review::-webkit-scrollbar,
.focus-view::-webkit-scrollbar {
    width: 8px;
}

.chat-history::-webkit-scrollbar-track,
.summary-content::-webkit-scrollbar-track,
.preview-content::-webkit-scrollbar-track,
#final-document-review::-webkit-scrollbar-track,
.focus-view::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 10px;
}

.chat-history::-webkit-scrollbar-thumb,
.summary-content::-webkit-scrollbar-thumb,
.preview-content::-webkit-scrollbar-thumb,
#final-document-review::-webkit-scrollbar-thumb,
.focus-view::-webkit-scrollbar-thumb {
    background: var(--aiu-primary);
    border-radius: 10px;
}

.chat-history::-webkit-scrollbar-thumb:hover,
.summary-content::-webkit-scrollbar-thumb:hover,
.preview-content::-webkit-scrollbar-thumb:hover,
#final-document-review::-webkit-scrollbar-thumb:hover,
.focus-view::-webkit-scrollbar-thumb:hover {
    background: #c084fc;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .studio-header {
        padding: 10px 15px;
        gap: 15px;
    }

    .studio-title {
        font-size: 1.1rem;
    }

    .title-icon {
        font-size: 1.3rem;
    }

    .view-cycler {
        gap: 10px;
    }

    .cycle-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .view-label {
        font-size: 0.9rem;
        min-width: 100px;
    }

    #conversation-view,
    #summary-view {
        padding: 0 15px 20px 15px;
    }

    #preview-view .preview-body {
        padding: 0 15px;
    }

    #preview-view .finalization-controls {
        padding: 15px;
    }

    .view-header-compact {
        padding: 12px 15px;
    }

    .view-header-compact h2 {
        font-size: 1.3rem;
    }

    .view-icon-inline {
        font-size: 1.5rem;
    }

    .summary-content {
        padding: 25px;
    }

    .chat-bubble {
        max-width: 90%;
        padding: 12px 16px;
    }

    .modal-content {
        margin: 10px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 20px;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn-primary,
    .modal-footer .btn-secondary {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .view-header-compact h2 {
        font-size: 1.2rem;
    }

    .btn-large {
        font-size: 1rem;
        padding: 14px 24px;
    }
}