/* ============================================
   AI ASSISTANT - iOS 26 DESIGN SYSTEM
   Fluid Glassmorphism • Adaptive Colors • Spring Animations
   ============================================ */

/* ============================================
   FLOATING BUTTON
   ============================================ */

.ai-floating-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007AFF 0%, #5E5CE6 100%);
    border: 0.5px solid rgba(255, 255, 255, 0.18);
    box-shadow:
        0 12px 40px -8px rgba(0, 122, 255, 0.42),
        0 4px 16px -4px rgba(0, 0, 0, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
}

.ai-floating-btn:hover {
    transform: scale(1.12) translateY(-2px);
    box-shadow:
        0 16px 48px -8px rgba(0, 122, 255, 0.5),
        0 6px 20px -4px rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.ai-floating-btn svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.ai-floating-btn.active {
    background: linear-gradient(135deg, #5E5CE6 0%, #007AFF 100%);
    box-shadow:
        0 8px 32px -8px rgba(94, 92, 230, 0.45),
        0 4px 16px -4px rgba(0, 0, 0, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

/* Pulse Animation für ungelesene Nachrichten */
.ai-floating-btn.has-notification::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: #ff4444;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* ============================================
   CHAT PANEL
   ============================================ */

.ai-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 420px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 150px);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    border-radius: 24px;
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    box-shadow:
        0 20px 60px -12px rgba(0, 0, 0, 0.18),
        0 8px 24px -8px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 998;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.ai-panel.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* ============================================
   HEADER
   ============================================ */

.ai-header {
    background: linear-gradient(135deg, #007AFF 0%, #5E5CE6 100%);
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    backdrop-filter: blur(32px) saturate(200%);
    -webkit-backdrop-filter: blur(32px) saturate(200%);
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.15);
    position: relative;
}

.ai-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
}

.ai-header h3 {
    margin: 0;
    color: white;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 4px;
}

.ai-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    transition: all 0.2s;
}

.ai-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ============================================
   MESSAGES CONTAINER
   ============================================ */

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ai-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */

.ai-message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

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

.ai-message.user {
    flex-direction: row-reverse;
}

.ai-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25);
}

.ai-avatar svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

.ai-message.user .ai-avatar {
    background: #6c757d;
}

.ai-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 75%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ai-message.user .ai-bubble {
    background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
    color: white;
}

.ai-bubble p {
    margin: 0 0 8px 0;
}

.ai-bubble p:last-child {
    margin-bottom: 0;
}

.ai-bubble h4 {
    margin: 12px 0 8px 0;
    font-size: 15px;
    color: #007AFF;
}

.ai-message.user .ai-bubble h4 {
    color: white;
}

/* Markdown Tables */
.ai-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.ai-bubble th,
.ai-bubble td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.ai-bubble th {
    background: #f8f9fa;
    font-weight: 600;
}

.ai-message.user .ai-bubble table {
    color: white;
}

.ai-message.user .ai-bubble th {
    background: rgba(255, 255, 255, 0.1);
}

/* Code Blocks */
.ai-bubble pre {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 8px 0;
}

.ai-bubble code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* ============================================
   INTERACTIVE ELEMENTS
   ============================================ */

.ai-interactive {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-quick-btn {
    background: white;
    border: 2px solid #007AFF;
    color: #007AFF;
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-quick-btn:hover {
    background: #007AFF;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.3);
}

.ai-quick-btn.selected {
    background: #007AFF;
    color: white;
}

.ai-input-field {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.ai-input-field input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
}

.ai-input-field input:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.ai-input-field button {
    background: #007AFF;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.ai-input-field button:hover {
    background: #0051D5;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    background: #007AFF;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ============================================
   INPUT AREA
   ============================================ */

.ai-input-area {
    padding: 16px 20px 20px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border-top: 0.5px solid rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    position: relative;
}

.ai-input-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.04), transparent);
}

.ai-input-area input {
    flex: 1;
    padding: 12px 18px;
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 24px;
    font-size: 15px;
    letter-spacing: -0.008em;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: #1d1d1f;
    box-shadow:
        0 2px 8px -2px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.ai-input-area input::placeholder {
    color: #86868b;
}

.ai-input-area input:focus {
    outline: none;
    border-color: rgba(0, 122, 255, 0.3);
    background: white;
    box-shadow:
        0 4px 16px -4px rgba(0, 122, 255, 0.12),
        0 0 0 3px rgba(0, 122, 255, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.ai-send-btn {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, #007AFF 0%, #5E5CE6 100%);
    border: 0.5px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow:
        0 8px 24px -8px rgba(0, 122, 255, 0.42),
        0 3px 12px -3px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
    position: relative;
}

.ai-send-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 0.5px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.08));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

.ai-send-btn:hover {
    transform: scale(1.12) translateY(-1px);
    box-shadow:
        0 12px 32px -8px rgba(0, 122, 255, 0.5),
        0 4px 16px -4px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* ============================================
   TOOL EXECUTION INDICATOR
   ============================================ */

.ai-tool-execution {
    background: rgba(0, 122, 255, 0.05);
    border: 1px solid rgba(0, 122, 255, 0.2);
    border-radius: 10px;
    padding: 12px;
    margin: 8px 0;
    font-size: 13px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ai-tool-execution-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #007AFF;
    margin-bottom: 8px;
}

.ai-tool-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 122, 255, 0.2);
    border-top-color: #007AFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.ai-tool-result {
    color: #666;
    margin-top: 4px;
}

/* ============================================
   WELCOME SCREEN
   ============================================ */

.ai-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.ai-welcome-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #007AFF 0%, #5E5CE6 100%);
    border-radius: 22px;
    border: 0.5px solid rgba(255, 255, 255, 0.18);
    box-shadow:
        0 16px 48px -12px rgba(0, 122, 255, 0.42),
        0 6px 20px -6px rgba(0, 0, 0, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    position: relative;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-welcome-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 22px;
    padding: 0.5px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

.ai-welcome-icon svg {
    width: 36px;
    height: 36px;
    stroke: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.ai-welcome h3 {
    margin: 0 0 10px 0;
    color: #1d1d1f;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.022em;
    line-height: 1.2;
}

.ai-welcome p {
    margin: 0 0 32px 0;
    font-size: 15px;
    line-height: 1.47;
    color: #86868b;
    letter-spacing: -0.008em;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
}

.ai-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ai-quick-action {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ai-quick-action:hover {
    border-color: rgba(0, 122, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    background: white;
}

.ai-quick-action-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-quick-action-icon svg {
    width: 24px;
    height: 24px;
    stroke: #007AFF;
    stroke-width: 2;
}

.ai-quick-action-label {
    font-size: 13px;
    font-weight: 500;
    color: #1d1d1f;
    letter-spacing: -0.01em;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .ai-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .ai-floating-btn {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .ai-floating-btn svg {
        width: 28px;
        height: 28px;
    }

    .ai-quick-actions {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   LOADING INDICATOR
   ============================================ */

.ai-loading {
    text-align: center;
    padding: 20px;
}

.ai-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 122, 255, 0.15);
    border-top-color: #007AFF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

.ai-loading-text {
    font-weight: 600;
    color: #007AFF;
    margin-bottom: 8px;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.ai-loading-subtext {
    color: #999;
    font-size: 12px;
}

/* ============================================
   INTERACTIVE BUTTON GROUPS
   ============================================ */

.ai-button-group {
    margin: 16px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
}

.ai-button-group-question {
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    font-size: 14px;
}

.ai-button-group-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ai-interactive-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color: #333;
}

.ai-interactive-btn:hover:not(:disabled) {
    border-color: #007AFF;
    background: rgba(0, 122, 255, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.15);
}

.ai-interactive-btn.selected {
    border-color: #007AFF;
    background: #007AFF;
    color: white;
}

.ai-interactive-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-btn-emoji {
    font-size: 28px;
    line-height: 1;
}

.ai-btn-label {
    font-weight: 500;
    text-align: center;
}

/* Mobile: Einzelne Spalte */
@media (max-width: 480px) {
    .ai-button-group-options {
        grid-template-columns: 1fr;
    }
}
