/* =========================================
   AI Asistan Page (ai.php) Stilleri
   ========================================= */
.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--card-shadow);
}

.ai-chat-history {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

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

.ai-chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.ai-message {
    display: flex;
    gap: 16px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

.ai-message.assistant {
    align-self: flex-start;
}

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

.ai-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: bold;
}

.ai-message.assistant .ai-avatar {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
}

.ai-message.user .ai-avatar {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

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

.ai-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-text {
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.ai-message.assistant .ai-text {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    border-top-left-radius: 4px;
}

.ai-message.user .ai-text {
    background: var(--accent);
    color: #fff;
    border-top-right-radius: 4px;
}

/* AI İşlem / Öneri Kartı */
.ai-action-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
    position: relative;
    overflow: hidden;
}

.ai-action-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent);
}

.ai-action-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-action-header svg {
    width: 16px;
    height: 16px;
    stroke: var(--accent);
}

.ai-action-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.ai-action-buttons {
    display: flex;
    gap: 10px;
}

.ai-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-btn-confirm {
    background: rgba(48, 92, 222, 0.15);
    color: var(--accent);
    border: 1px solid rgba(48, 92, 222, 0.3);
}

.ai-btn-confirm:hover {
    background: rgba(48, 92, 222, 0.25);
}

.ai-btn-reject {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.ai-btn-reject:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Suggestions Area */
.ai-suggestions {
    padding: 12px 24px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    border-top: 1px solid var(--card-border);
}

.ai-suggestions::-webkit-scrollbar {
    height: 4px;
}

.ai-suggestions::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.ai-sug-btn {
    white-space: nowrap;
    padding: 8px 16px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
}

.ai-sug-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Input Area */
.ai-input-wrapper {
    padding: 16px 24px 24px;
    background: var(--card-bg);
}

.ai-input-area {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 12px 16px;
    transition: border-color var(--transition);
}

.ai-input-area:focus-within {
    border-color: rgba(255, 255, 255, 0.2);
}

.ai-input-textarea-wrapper {
    flex: 1;
    min-height: 24px;
}

#ai-chat-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 120px;
    font-family: inherit;
}

#ai-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.ai-input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.ai-mic-btn,
.ai-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.ai-mic-btn {
    background: transparent;
    color: var(--text-secondary);
}

.ai-mic-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.ai-mic-btn.recording {
    color: #ef4444;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

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

.ai-send-btn {
    background: var(--accent);
    color: #fff;
}

.ai-send-btn:hover {
    background: #254bbf;
    transform: translateY(-1px);
}

.ai-send-btn svg,
.ai-mic-btn svg {
    width: 18px;
    height: 18px;
}

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

/* Typing Indicator */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    width: fit-content;
}

.ai-typing span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.ai-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes typing {

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

    40% {
        transform: scale(1);
    }
}

@media (max-width: 768px) {
    .ai-chat-container {
        height: calc(100vh - 120px);
        border: none;
        border-radius: 0;
        margin: -24px -16px;
    }

    .ai-chat-history {
        padding: 16px;
    }

    .ai-input-wrapper {
        padding: 12px 16px;
    }
}

/* =========================================
   AI Koç & Asistan (Dual-Pane) Stilleri
   ========================================= */

#page-ai .main-header {
    margin-bottom: 20px;
}

.ai-layout-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    height: calc(100vh - 160px);
    min-height: 500px;
}

@media (max-width: 992px) {
    .ai-layout-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
}

/* --- Sol Kolon: AI Koç Panosu --- */
.ai-coach-panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-coach-panel .panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-title .icon {
    font-size: 1.2rem;
}

.panel-title h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.refresh-suggestions-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.refresh-suggestions-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.refresh-suggestions-btn svg {
    width: 16px;
    height: 16px;
}

.refresh-suggestions-btn.spinning svg {
    animation: spin 1s linear infinite;
}

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

.suggestions-list {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.suggestions-list::-webkit-scrollbar {
    width: 4px;
}

.suggestions-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Coach Loading State */
.coach-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
    padding: 20px;
}

.coach-loading-state .spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.coach-loading-state p {
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Koç Öneri Kartı */
.coach-suggestion-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    transition: all var(--transition);
    animation: slideIn 0.3s ease forwards;
}

.coach-suggestion-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

.coach-suggestion-card .suggestion-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 14px;
}

.suggestion-actions {
    display: flex;
    gap: 8px;
}

.btn-card-action {
    flex: 1;
    padding: 8px 0;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    text-align: center;
}

.btn-sug-approve {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.btn-sug-approve:hover {
    background: color-mix(in srgb, var(--accent) 25%, transparent);
}

.btn-sug-reject {
    background: transparent;
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-sug-reject:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* --- Sağ Kolon: Sohbet Alanı --- */
.ai-chat-container {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.ai-chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

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

.ai-chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.ai-message {
    display: flex;
    gap: 16px;
    max-width: 85%;
    animation: slideIn 0.3s ease forwards;
}

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

.ai-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.assistant .ai-avatar {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

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

.user .ai-avatar {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
}

.ai-text {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px 18px;
    border-radius: 2px 16px 16px 16px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    word-break: break-word;
}

.user .ai-text {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
    border-radius: 16px 2px 16px 16px;
}

/* Typing Indicator */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 2px 16px 16px 16px;
    width: fit-content;
}

.ai-typing span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.ai-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes typing {

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

    40% {
        transform: scale(1);
    }
}

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

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

/* Action Card (Tool Call) inside Chat */
.ai-action-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 8px;
    width: 100%;
    min-width: 280px;
}

.action-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.action-icon {
    font-size: 1.1rem;
}

.action-details {
    padding: 16px;
}

.action-details p {
    margin: 0 0 6px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.action-details p:last-child {
    margin: 0;
}

.action-details strong {
    color: var(--text-primary);
}

.action-actions {
    padding: 0 16px 16px 16px;
    display: flex;
    gap: 10px;
}

.action-card-result {
    padding: 12px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.action-card-result.success {
    color: var(--accent);
}

.action-card-result.rejected {
    color: #ef4444;
}

/* Input Area */
.ai-input-wrapper {
    padding: 20px;
    background: var(--card-bg);
    border-top: 1px solid var(--card-border);
}

.ai-input-area {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 8px 12px;
    transition: border-color var(--transition);
}

.ai-input-area:focus-within {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
}

.ai-mic-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    margin-bottom: 2px;
}

.ai-mic-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.ai-mic-btn.recording {
    color: #ef4444;
    animation: pulseMic 1.5s infinite;
}

@keyframes pulseMic {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

#ai-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 10px 0;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: auto;
}

#ai-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.ai-send-btn {
    background: var(--accent);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    margin-bottom: 2px;
}

.ai-send-btn:hover {
    transform: scale(1.05);
    background: #0d9668;
}

.ai-send-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.ai-input-footer {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 12px;
}