/* VTXR SYSTEMS CHAT - iOS Inspire Modern Design */

:root {
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --accent-primary: #0a84ff;
    --accent-gradient: linear-gradient(135deg, #0a84ff 0%, #007aff 100%);
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --text-muted: #636366;
    --border-color: #38383a;
    --glass-bg: rgba(28, 28, 30, 0.85);
    --message-user: #0a84ff;
    --message-bot: #2c2c2e;
    --shadow-glow: 0 0 20px rgba(10, 132, 255, 0.3);
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-stack);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    font-size: 16px;
    line-height: 1.4;
}

/* Animierter Hintergrund (Dezenter) */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 50% -20%, #1a1a2e 0%, #000000 60%);
}

/* Container */
.app-container {
    display: flex;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    max-width: 1400px;
    margin: 0 auto;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 0.5px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.logo-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Character Profile */
.character-profile {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 0.5px solid var(--border-color);
}

.avatar-container {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 15px;
    cursor: pointer;
}

.avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.character-name {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.character-status {
    color: var(--text-secondary);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #30d158;
    border-radius: 50%;
}

/* Form Styles */
.character-editor {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
}

.btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    margin-bottom: 12px;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: black;
    position: relative;
}

.chat-header {
    height: 60px;
    padding: 0 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 10;
}

.chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-header-info h2 {
    font-size: 16px;
    font-weight: 600;
}

.chat-header-info span {
    font-size: 12px;
    color: var(--text-secondary);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 24px;
    cursor: pointer;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 80px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bot {
    align-self: flex-start;
}

.message-user {
    align-self: flex-end;
    align-items: flex-end;
}

.message-content {
    padding: 10px 16px;
    font-size: 16px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message-bot .message-content {
    background: var(--bg-tertiary);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

.message-user .message-content {
    background: var(--message-user);
    color: white;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
}

.message-image {
    max-width: 260px;
    border-radius: 18px;
    margin-bottom: 4px;
    display: block;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

.bot-avatar-small {
    display: none;
    /* Hide small avatar in message */
}

/* Audio Player */
.audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
}

.play-btn {
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
    cursor: pointer;
}

/* Typing Indicator */
.typing-indicator {
    padding: 0 20px;
    margin-bottom: 15px;
    display: none;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* Chat Input */
.chat-input-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--border-color);
    padding: 10px 16px 30px;
    /* Extra padding for iPhone home indicator */
    position: relative;
    z-index: 20;
}

.image-preview-container {
    padding: 10px;
    display: none;
}

.image-preview {
    height: 100px;
    border-radius: 12px;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    padding: 8px 12px;
    border: 1px solid transparent;
}

.chat-input-wrapper:focus-within {
    border-color: var(--text-secondary);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    max-height: 100px;
    padding: 8px 0;
    resize: none;
}

.chat-input:focus {
    outline: none;
}

.input-actions {
    display: flex;
    gap: 8px;
    padding-bottom: 4px;
}

.input-btn {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
}

.send-btn {
    color: #30d158;
}

/* Call Overlay */
.call-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
}

.call-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
}

.call-content {
    position: relative;
    z-index: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.call-avatar-container {
    width: 150px;
    height: 150px;
    position: relative;
    margin-bottom: 25px;
}

.call-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    z-index: 2;
    position: relative;
}

.call-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(10, 132, 255, 0.3);
    z-index: 1;
    animation: pulse 2s infinite;
}

.call-pulse-ring.delay {
    animation-delay: 1s;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }

    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

.call-name {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.call-status {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 60px;
}

.call-controls {
    display: flex;
    gap: 40px;
}

.call-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    cursor: pointer;
    transition: transform 0.1s;
}

.call-btn:active {
    transform: scale(0.95);
}

.end-call {
    background: #ff3b30;
    color: white;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: block;
    }

    .chat-messages {
        padding-top: 70px;
    }

    .message {
        max-width: 85%;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* Animierter Hintergrund */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.bg-animation::before {
    content: '';
    position: absolute;
    width: 150%;
    height: 150%;
    top: -25%;
    left: -25%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
    animation: bgMove 20s ease-in-out infinite;
}

@keyframes bgMove {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    50% {
        transform: translate(-5%, -5%) rotate(5deg);
    }
}

/* Container */
.app-container {
    display: flex;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    max-width: 1400px;
    margin: 0 auto;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 340px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow-glow);
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Character Profile */
.character-profile {
    padding: 25px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.avatar-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 15px;
    cursor: pointer;
}

.avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-primary);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
    transition: transform 0.3s ease;
}

.avatar-container:hover .avatar {
    transform: scale(1.05);
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
}

.avatar-overlay {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.avatar-overlay:hover {
    transform: scale(1.1);
}

.character-name {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
}

.character-status {
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Character Editor Form */
.character-editor {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    width: 100%;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    width: 100%;
    margin-top: 10px;
}

.btn-secondary:hover {
    background: var(--bg-secondary);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.chat-header {
    padding: 16px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-header-info h2 {
    font-size: 16px;
    font-weight: 600;
}

.chat-header-info span {
    font-size: 13px;
    color: #22c55e;
}

.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 20px;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding-bottom: 20px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 75%;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message-content {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
}

.message-user .message-content {
    background: var(--message-user);
    border-bottom-right-radius: 6px;
}

.message-bot .message-content {
    background: var(--message-bot);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 6px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: right;
}

.message-bot .message-time {
    text-align: left;
}

.message-image {
    max-width: 280px;
    border-radius: 16px;
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-image:hover {
    transform: scale(1.02);
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    margin-bottom: 16px;
}

.typing-indicator.active {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: var(--message-bot);
    border: 1px solid var(--border-color);
    border-radius: 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-8px);
    }
}

/* Chat Input */
.chat-input-container {
    padding: 16px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 8px 16px;
    transition: border-color 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: var(--accent-primary);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 8px 0;
    resize: none;
    max-height: 120px;
    font-family: inherit;
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    gap: 4px;
}

.input-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.input-btn:hover {
    color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.1);
}

.input-btn.send-btn {
    background: var(--accent-gradient);
    color: white;
}

.input-btn.send-btn:hover {
    transform: scale(1.1);
}

/* Image Preview */
.image-preview-container {
    display: none;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    margin-bottom: 12px;
    position: relative;
}

.image-preview-container.active {
    display: block;
}

.image-preview {
    max-width: 200px;
    max-height: 150px;
    border-radius: 12px;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .message {
        max-width: 85%;
    }

    .app-container {
        flex-direction: column;
        height: 100dvh;
        overflow: hidden;
    }

    .chat-area {
        height: 100dvh;
        display: flex;
        flex-direction: column;
    }

    .chat-messages {
        flex: 1;
        overflow-y: scroll;
    }
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.image-modal.active {
    display: flex;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
}