/* Singular Office - iPhone Optimized */

:root {
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-header: #151522;
    --border-color: #2a2a3a;
    
    --neon-purple: #9d4edd;
    --neon-blue: #00f3ff;
    --neon-pink: #ff0080;
    --neon-green: #00ff9d;
    
    --text-primary: #f0f0ff;
    --text-secondary: #a0a0c0;
    --text-muted: #707090;
    
    --user-bg: rgba(157, 78, 221, 0.15);
    --assistant-bg: rgba(0, 243, 255, 0.1);
    
    --radius: 12px;
    --radius-sm: 6px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', 'Roboto', -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    max-width: 100vw;
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

body.light-theme {
    --bg-dark: #f5f5f7;
    --bg-card: #ffffff;
    --bg-header: #ffffff;
    --border-color: #e0e0e5;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --user-bg: rgba(157, 78, 221, 0.1);
    --assistant-bg: rgba(0, 243, 255, 0.05);
}

.container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 100svh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ===== HEADER (ULTRA COMPACT) ===== */
.header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 7px 10px;
    flex-shrink: 0;
    position: relative;
    max-width: 100%;
    overflow: hidden;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--neon-purple), transparent);
    opacity: 0.5;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    gap: 4px;
}

.header h1 {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, var(--neon-purple), var(--neon-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    flex-shrink: 1;
}

.header h1 i {
    background: none;
    -webkit-text-fill-color: unset;
    background-clip: unset;
    color: var(--neon-purple);
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ===== MODEL PICKER ===== */
.runtime-badge {
    margin-top: 4px;
    padding: 6px 8px;
    border: 1px solid rgba(0, 243, 255, 0.18);
    border-radius: var(--radius-sm);
    background: rgba(0, 243, 255, 0.06);
    color: var(--text-secondary);
    font-size: 0.68rem;
    line-height: 1.3;
}

.model-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.picker-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.picker-chip {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 34px;
    white-space: nowrap;
}

.picker-chip:hover {
    border-color: var(--neon-purple);
    color: var(--text-primary);
}

.picker-chip.active {
    background: linear-gradient(135deg, rgba(157, 78, 221, 0.22), rgba(0, 243, 255, 0.16));
    border-color: rgba(0, 243, 255, 0.5);
    color: var(--text-primary);
    box-shadow: 0 0 0 1px rgba(0, 243, 255, 0.15) inset;
}

.picker-chip:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.model-selector {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 4px;
    margin-top: 4px;
}

.model-selector-hidden {
    display: none;
}

.select-input {
    width: 100%;
    min-width: 0;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.select-input:focus {
    outline: none;
    border-color: var(--neon-purple);
    box-shadow: 0 0 0 2px rgba(157, 78, 221, 0.3), 0 0 10px rgba(157, 78, 221, 0.4);
}

.select-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.72rem;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-height: 30px;
    white-space: nowrap;
}

.btn:hover {
    background-color: rgba(157, 78, 221, 0.1);
    border-color: var(--neon-purple);
    transform: translateY(-2px);
}

.btn-send {
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-blue));
    color: white;
    border: none;
    padding: 0;
    font-weight: 700;
    min-height: 44px;
    width: 52px;
    font-size: 0.9rem;
}

.send-label {
    display: none;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(157, 78, 221, 0.4);
}

/* ===== MAIN CONTENT (CHAT FOCUS) ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 8px;
    padding: 8px 0;
    min-height: 0;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-height: 0;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: var(--neon-purple);
}

/* ===== MESSAGES ===== */
.message {
    max-width: 88%;
    min-width: 0;
    padding: 11px 12px;
    border-radius: var(--radius);
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
    border: 1px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    font-size: 0.95rem;
}

.message.error {
    border-color: rgba(255, 0, 128, 0.35);
    background: rgba(255, 0, 128, 0.08);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
    background-color: var(--user-bg);
    border-color: rgba(157, 78, 221, 0.3);
    margin-right: 12px;
    margin-left: 12%;
}

.message.assistant {
    align-self: flex-start;
    background-color: var(--assistant-bg);
    border-color: rgba(0, 243, 255, 0.3);
    margin-left: 12px;
    margin-right: 12%;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.message-label {
    font-weight: 700;
    color: var(--neon-blue);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7rem;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.8;
    font-family: 'Roboto Mono', monospace;
}

.message-runtime {
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.68rem;
}

.message-content {
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 0.95rem;
    word-break: break-word;
}

.message.typing .message-content {
    display: flex;
    gap: 3px;
    align-items: center;
}

.dot {
    animation: pulse 1.4s infinite;
    color: var(--neon-blue);
    font-size: 1.2rem;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

.welcome-message {
    background-color: var(--bg-card);
    padding: 20px 16px;
    border-radius: var(--radius);
    border: 2px dashed var(--border-color);
    text-align: center;
    margin: 12px 0;
    font-size: 0.9rem;
}

.welcome-message p {
    margin-bottom: 8px;
}

.welcome-message p:first-child {
    font-size: 1rem;
    font-weight: 700;
    color: var(--neon-purple);
}

.copy-btn {
    background: none;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0.6;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    margin-left: 6px;
}

.copy-btn:hover {
    opacity: 1;
    background-color: rgba(157, 78, 221, 0.1);
    color: var(--neon-purple);
}

.floating-notification {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0) + 12px);
    right: 12px;
    left: 12px;
    z-index: 9999;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(20, 20, 30, 0.96);
    border: 1px solid rgba(157, 78, 221, 0.45);
    color: var(--text-primary);
    font-size: 0.86rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ===== VOICE MODE SELECTOR ===== */
.voice-mode-selector {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.voice-mode-selector label {
    color: var(--text-secondary);
    font-weight: 600;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.mode-option:hover {
    background-color: rgba(157, 78, 221, 0.1);
}

.mode-option input {
    cursor: pointer;
    width: 14px;
    height: 14px;
}

.mode-option span {
    font-size: 0.8rem;
    color: var(--text-primary);
}

/* ===== INPUT AREA ===== */
.input-area {
    flex-shrink: 0;
    background-color: var(--bg-header);
    border-top: 1px solid var(--border-color);
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0));
    max-width: 100%;
    overflow: hidden;
}

.input-area::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--neon-blue), transparent);
    opacity: 0.5;
}

.input-wrapper {
    display: flex;
    gap: 6px;
    align-items: stretch;
    min-width: 0;
}

.input-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    flex: 0 0 52px;
    width: 52px;
}

.btn-audio {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    min-height: 44px;
    width: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-audio:hover {
    background-color: rgba(157, 78, 221, 0.1);
    border-color: var(--neon-purple);
}

.btn-audio.is-recording {
    background: rgba(255, 71, 87, 0.18);
    border-color: #ff4757;
    color: #ff9da7;
}

.btn-audio:active {
    transform: translateY(1px);
}

textarea {
    flex: 1;
    min-width: 0;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 16px;
    resize: none;
    min-height: 52px;
    max-height: 128px;
    line-height: 1.45;
    transition: all 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--neon-purple);
    box-shadow: 0 0 0 2px rgba(157, 78, 221, 0.25), 0 0 15px rgba(157, 78, 221, 0.3);
}

textarea::placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: rgba(157, 78, 221, 0.08);
    font-size: 0.75rem;
}

.attachment-chip-preview {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
    flex: 0 0 28px;
}

.attachment-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.attachment-chip-remove {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
}

.input-hints {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 2px;
}

/* ===== QUICK ACTIONS BAR (2 COLUMNS, COMPACT) ===== */
.quick-actions-bar {
    flex-shrink: 0;
    background-color: var(--bg-header);
    border-top: 1px solid var(--border-color);
    padding: 6px 10px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    max-width: 100%;
    overflow: hidden;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
}

.action-btn {
    padding: 7px 8px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-size: 0.68rem;
    min-height: 34px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 0;
    white-space: nowrap;
}

.action-btn i {
    font-size: 0.78rem;
    flex-shrink: 0;
}

.action-btn:active {
    background-color: rgba(157, 78, 221, 0.2);
    border-color: var(--neon-purple);
}

/* ===== AUDIO PLAYER ===== */
.message-attachments {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    text-decoration: none;
    border: 1px solid rgba(157, 78, 221, 0.18);
    border-radius: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.attachment-file i {
    color: var(--neon-blue);
}

.attachment-image {
    flex-direction: column;
    align-items: flex-start;
}

.attachment-image img {
    display: block;
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 8px;
}

.attachment-video,
.attachment-audio {
    display: grid;
    gap: 6px;
}

.attachment-video video,
.attachment-audio audio {
    width: 100%;
    max-width: 100%;
}

.audio-player {
    margin-top: 8px;
    padding: 8px 0;
    border-top: 1px solid rgba(157, 78, 221, 0.2);
}

.audio-player audio {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 32px;
    border-radius: 4px;
}

/* ===== FOOTER ===== */
.footer {
    flex-shrink: 0;
    padding: 6px 10px;
    border-top: 1px solid var(--border-color);
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: center;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
    .header {
        padding: 12px 16px;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .model-selector {
        gap: 10px;
    }
    
    .select-input {
        padding: 10px 12px;
        font-size: 16px;
    }
    
    .chat-history {
        padding: 0 16px;
        gap: 12px;
    }
    
    .message {
        max-width: 85%;
        padding: 14px 16px;
        font-size: 1rem;
    }
    
    .message.user {
        margin-right: 16px;
        margin-left: 15%;
    }
    
    .message.assistant {
        margin-left: 16px;
        margin-right: 15%;
    }
    
    .input-area {
        padding: 12px 16px;
    }

    .input-buttons {
        flex-direction: row;
        width: auto;
        flex: 0 0 auto;
    }

    .btn-audio,
    .btn-send {
        width: auto;
        min-width: 52px;
        padding: 0 14px;
    }

    .send-label {
        display: inline;
    }
    
    .actions-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    
    .action-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
        min-height: 44px;
        gap: 6px;
    }
}
