/* Foreman HR AI Chat Window Styles */

/* Mobile viewport fix */
@viewport {
    width: device-width;
    initial-scale: 1;
}

/* Chat Container - holds both window and Doug's panel */
.foreman-chat-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    display: flex;
    gap: 20px;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
}

.foreman-chat-container.chat-open {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.foreman-chat-container.chat-closing {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
}

/* Court panel removed - AI personality preserved in system prompt */

/* Chat Backdrop */
.chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.foreman-chat-window {
    width: 850px;
    height: calc(100vh - 60px);
    max-height: 90vh;
    background: linear-gradient(135deg, #2C3E50 0%, #34495E 100%);
    border: 3px solid #FFB000;
    border-radius: 15px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(255, 176, 0, 0.2);
    display: flex;
    flex-direction: column;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #FFB000 0%, #FF7A00 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 16px;
}

.helmet-icon {
    font-size: 24px;
}

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

.chat-close:hover {
    background: #DC143C;
    transform: rotate(90deg);
}

/* Chat Subheader */
.chat-subheader {
    background: rgba(255, 176, 0, 0.1);
    padding: 10px 20px;
    border-bottom: 2px solid rgba(255, 176, 0, 0.3);
}

.chat-subheader p {
    margin: 0;
    color: #FFE66D;
    font-style: italic;
    font-size: 14px;
}

/* Chat Body Container */
.chat-body-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0; /* Important for nested flexbox */
}

/* Chat Sidebar */
.chat-sidebar {
    width: 250px;
    background: linear-gradient(135deg, #1a1f25 0%, #2a3540 100%);
    border-left: 2px solid rgba(255, 176, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    background: rgba(255, 176, 0, 0.15);
    padding: 12px;
    border-bottom: 2px solid rgba(255, 176, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #FFB000;
}

.sidebar-content {
    padding: 15px;
    font-size: 12px;
    color: #E0E0E0;
}

.reason-item {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reason-label {
    color: #FFB000;
    font-weight: bold;
    font-size: 11px;
    text-transform: uppercase;
}

.reason-value {
    color: #B0BEC5;
    font-style: italic;
}

.reason-divider {
    height: 1px;
    background: rgba(255, 176, 0, 0.2);
    margin: 15px 0;
}

.reason-warning {
    background: rgba(220, 20, 60, 0.15);
    border: 1px solid rgba(220, 20, 60, 0.3);
    border-radius: 5px;
    padding: 10px;
    color: #FF6B6B;
    font-size: 11px;
}

.reason-warning strong {
    color: #DC143C;
    display: block;
    margin-bottom: 5px;
}

.reason-warning ul {
    margin: 5px 0 0 0;
    padding: 0;
    list-style: none;
}

.reason-warning li {
    margin: 3px 0;
    color: #FFB8B8;
}

.reason-motto {
    background: rgba(255, 176, 0, 0.1);
    border-left: 3px solid #FFB000;
    padding: 10px;
    margin-top: 10px;
    color: #FFE66D;
    font-size: 12px;
    text-align: center;
}

.reason-motto small {
    color: #B0BEC5;
    font-size: 10px;
    margin-top: 5px;
    display: block;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin: 10px;
    min-height: 0; /* Important for flexbox */
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 176, 0, 0.5);
    border-radius: 4px;
}

/* Chat Messages - Clean Style */
.chat-message {
    margin-bottom: 15px;
    animation: messageSlide 0.3s ease;
}

.chat-message.user {
    text-align: right;
}

.chat-message.assistant {
    text-align: left;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    font-size: 12px;
}

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

.message-header strong {
    color: #FFB000;
    font-weight: bold;
}

.timestamp {
    color: #8B92A9;
    font-size: 11px;
    opacity: 0.7;
}

.message-content {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 15px;
    display: inline-block;
    max-width: 75%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #E0E0E0;
    line-height: 1.5;
    font-size: 14px;
}

.chat-message.user .message-content {
    background: rgba(78, 205, 196, 0.2);
    border-color: rgba(78, 205, 196, 0.5);
    text-align: left;
}

.chat-message.assistant .message-content {
    background: rgba(255, 176, 0, 0.1);
    border-color: rgba(255, 176, 0, 0.3);
}

/* Old message style for backwards compatibility */
.message {
    display: flex;
    gap: 12px;
    animation: messageSlide 0.3s ease;
    width: 100%;
    margin-bottom: 10px;
}

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

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

.message-avatar {
    font-size: 28px;
    flex-shrink: 0;
}

.message-content {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 16px;
    max-width: 75%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.message-content strong {
    color: #FFB000;
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
}

.message-content p {
    margin: 0;
    color: #E0E0E0;
    line-height: 1.5;
    font-size: 14px;
}

.user-message {
    background: rgba(78, 205, 196, 0.2);
    border-color: rgba(78, 205, 196, 0.5);
}

.user-message strong {
    color: #4ECDC4;
}

/* Typing Indicator */
.typing .message-content {
    padding: 15px 20px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    margin-bottom: 5px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #FFB000;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

.typing em {
    color: #B0BEC5;
    font-size: 12px;
}

/* Input Area - Improved Spacing */
.chat-input-area {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 2px solid rgba(255, 176, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    box-sizing: border-box;
}

#chatInput {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 176, 0, 0.3);
    border-radius: 12px;
    padding: 15px 20px;
    color: white;
    font-size: 14px;
    resize: none;
    transition: all 0.3s ease;
    min-height: 50px;
    box-sizing: border-box;
}

#chatInput:focus {
    outline: none;
    border-color: #FFB000;
    background: rgba(255, 255, 255, 0.15);
}

#chatInput::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Chat Actions - Full Width Layout */
.chat-actions {
    display: flex;
    gap: 15px;
    align-items: stretch;
    width: 100%;
}

.chat-send,
.chat-preset {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 45px;
}

.chat-send {
    background: linear-gradient(135deg, #FFB000 0%, #FF7A00 100%);
    color: white;
    flex-grow: 1;
    flex-basis: 0;
    font-size: 14px;
}

.chat-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 176, 0, 0.4);
}

.chat-preset {
    background: rgba(220, 20, 60, 0.2);
    color: #FF6B6B;
    border: 2px solid #DC143C;
    flex-shrink: 0;
    flex-grow: 0;
    width: 180px;
    font-size: 13px;
}

.chat-preset:hover {
    background: rgba(220, 20, 60, 0.3);
    transform: scale(1.02);
}

.send-icon,
.rage-icon {
    font-size: 18px;
}

/* Chat Footer */
.chat-footer {
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 0 0 12px 12px;
}

.chat-footer p {
    margin: 3px 0;
    color: #B0BEC5;
    font-size: 11px;
    text-align: center;
}

.api-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #FFC107;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Responsive Design */
@media (max-width: 1400px) {
    .foreman-chat-container {
        flex-direction: column;
        align-items: center;
        max-width: 95vw;
    }

    .court-intro-panel {
        width: 100%;
        max-width: 850px;
        height: auto;
        max-height: 200px;
        margin-bottom: 20px;
    }

    .foreman-chat-window {
        width: 100%;
        max-width: 850px;
        height: calc(100vh - 300px);
    }
}

@media (max-width: 900px) {
    .foreman-chat-container {
        gap: 10px;
    }

    .foreman-chat-window {
        width: 95vw;
        height: calc(100vh - 250px);
    }

    .court-intro-panel {
        width: 95vw;
        padding: 15px;
    }

    .chat-sidebar {
        width: 180px;
    }
}

/* Court styles removed - personality preserved in AI system prompt */

/* Adjust chat window width for all screen sizes */
@media (max-width: 900px) {
    .foreman-chat-container {
        max-width: 90%;
    }

    .foreman-chat-window {
        width: 90% !important;
        max-width: 90%;
    }
}

/* Mobile Design - Full Screen Takeover */
@media (max-width: 700px) {
    /* Full screen backdrop */
    .chat-backdrop {
        background: rgba(0, 0, 0, 0.95);
    }

    /* Container takes full screen */
    .foreman-chat-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        transform: none !important;
        gap: 0;
        flex-direction: column;
    }

    .foreman-chat-container.chat-open {
        transform: none !important;
    }

    /* Court panel removed completely */

    /* Main chat window fills rest */
    .foreman-chat-window {
        width: 100%;
        height: 100%;
        flex: 1;
        border-radius: 0;
        border: none;
        max-height: none;
    }

    /* Optimize header for mobile */
    .chat-header {
        padding: 2% 3%;
        border-radius: 0;
    }

    .chat-title {
        font-size: 0.875rem;  /* 14px equivalent */
    }

    .helmet-icon {
        font-size: 1.25rem;  /* 20px equivalent */
    }

    /* Subheader smaller */
    .chat-subheader {
        padding: 1.5% 3%;
        font-size: 0.75rem;  /* 12px equivalent */
    }

    /* Body container */
    .chat-body-container {
        flex: 1;
        min-height: 0;
    }

    /* Chat sidebar hidden on mobile */
    .chat-sidebar {
        display: none;
    }

    /* Messages area optimization */
    .chat-messages {
        padding: 2%;
        margin: 1%;
        gap: 2%;
    }

    /* Message bubbles mobile optimized */
    .chat-message .message-content {
        max-width: 85%;
        font-size: 0.875rem;  /* 14px equivalent */
        padding: 2% 3%;
    }

    .message-header {
        font-size: 0.688rem;  /* 11px equivalent */
    }

    .timestamp {
        font-size: 0.625rem;  /* 10px equivalent */
    }

    /* Input area mobile friendly */
    .chat-input-area {
        padding: 2%;
        border-top: 2px solid rgba(255, 176, 0, 0.3);
    }

    #chatInput {
        font-size: 1rem; /* 16px - Prevents zoom on iOS */
        padding: 3%;
        border-radius: 12px;
        min-height: 50px;
        max-height: 25%;  /* 25% of parent height */
    }

    /* Chat actions mobile optimized */
    .chat-actions {
        display: flex;
        flex-direction: column;
        gap: 2%;
        margin-top: 2%;
    }

    .chat-send,
    .chat-preset {
        width: 100%;
        padding: 3%;
        font-size: 0.875rem;  /* 14px equivalent */
        border-radius: 10px;
        min-height: 44px;  /* iOS touch target */
    }

    /* Footer compact */
    .chat-footer {
        padding: 1.5% 2%;
        border-radius: 0;
    }

    .chat-footer p {
        font-size: 0.625rem;  /* 10px equivalent */
    }

    /* Close button more prominent */
    .chat-close {
        width: 44px;  /* iOS touch target */
        height: 44px;
        font-size: 1.75rem;  /* 28px equivalent */
    }

    /* Touch-friendly spacing */
    button {
        min-height: 44px; /* iOS touch target */
        touch-action: manipulation; /* Prevent double-tap zoom */
    }

    /* Prevent iOS rubber banding */
    .chat-messages {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Better message layout on small screens */
    .chat-message.user .message-content {
        margin-left: auto;
        background: linear-gradient(135deg, #2563EB, #3B82F6);
    }

    .chat-message.assistant .message-content {
        margin-right: auto;
        background: linear-gradient(135deg, #DC2626, #EF4444);
    }

    /* Typing indicator mobile size */
    .typing-indicator {
        padding: 2%;
    }

    .typing-dot {
        width: 0.375rem;  /* 6px equivalent */
        height: 0.375rem;
    }


    /* Prevent text selection on mobile */
    .court-panel-content,
    .chat-header,
    .chat-subheader {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Smooth scrolling */
    .chat-messages {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Hide typing indicator text on mobile */
    .typing em {
        display: none;
    }
}

/* Landscape mobile optimization */
@media (max-width: 900px) and (orientation: landscape) {
    .court-intro-panel {
        max-height: 80px;
    }

    .chat-messages {
        padding: 8px;
    }

    .chat-input-area {
        padding: 8px;
    }

    #chatInput {
        min-height: 40px;
        padding: 8px;
    }

    .chat-actions {
        flex-direction: row;
    }

    .chat-footer {
        display: none; /* Hide footer in landscape to save space */
    }
}

@media (max-height: 700px) {
    .foreman-chat-window,
    .court-intro-panel {
        height: calc(100vh - 40px);
        max-height: 95vh;
    }
}

/* Helmet Click Hint */
.foreman-svg path[fill="#ffb000"] {
    transition: all 0.3s ease;
}

.foreman-svg path[fill="#ffb000"]:hover {
    filter: brightness(1.2);
    cursor: pointer;
}

/* Add pulsing animation to helmet after page load */
@keyframes helmetPulse {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.3) drop-shadow(0 0 10px #FFB000);
    }
}

.helmet-clickable {
    animation: helmetPulse 3s ease infinite;
}

/* Visual hint for clickable helmet */
.foreman-svg g:first-child {
    transition: all 0.3s ease;
    pointer-events: auto;
}

.foreman-svg g:first-child path,
.foreman-svg g:first-child rect {
    pointer-events: auto;
}

.foreman-svg g:first-child:hover path,
.foreman-svg g:first-child:hover rect {
    filter: drop-shadow(0 0 8px #FFB000);
}

/* Debug helper - shows click area */
.helmet-clickable {
    outline: 2px dashed transparent;
}

.helmet-clickable:hover {
    outline-color: rgba(255, 176, 0, 0.3);
}

/* Tooltip styling */
.helmet-tooltip {
    position: absolute;
    background: #FFB000;
    color: #2C3E50;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 5px;
}

.helmet-tooltip.show {
    opacity: 1;
}

.helmet-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #FFB000;
}