@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* Styles for the RealTimeChatMessages component */
:root {
    --primary-color: #53AF31;
    --secondary-color: #478F2A;
    --tertiary-color: #26b050;
    --primary-hover-color: #478F2A;
    --background-color: #ffffff;
    --background-button-color: #53AF31;
    --border-color: #e0e0e0;
    --text-color: #333333;
    --button-text-color: #ffffff;
    --link-color: #53AF31;
    --error-color: #ff0000;
    --sidebar-bg: #f9f9f9;
    --panel-bg: #ffffff;
    --panel-header-bg: #f9f9f9;
}

/* Dark theme variables */
[data-theme='dark'] {
    --primary-color: #53AF31;
    --primary-hover-color: #478F2A;
    --background-color: #2d2d2d;
    --border-color: #444444;
    --text-color: #dee2e6;
    --link-color: #53AF31;
    --error-color: #ff5555;
    --sidebar-bg: #252525;
    --panel-bg: #2d2d2d;
    --panel-header-bg: #333;
}


html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.role-selection-box {
    height: 120px; /* Adjust the height to fit 4 roles */
    overflow-y: auto; /* Add scrollbar if content exceeds height */
    border: 1px solid #ccc; /* Optional: to visually delineate the box */
    border-radius: 4px; /* Optional: to add rounded corners */
    padding: 10px; /* Optional: spacing inside the box */
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--link-color);
}

.btn-primary {
    color: var(--button-text-color);
    background-color: var(--primary-color);
    border-color: var(--secondary-color);
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--tertiary-color);
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,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MiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    text-align: center;
    line-height: 20px;
    transition: width 0.5s;
}

/* Tab navigation */
.tab-buttons {
    display: flex;
    margin-bottom: 10px;
}

.tab-button {
    padding: 8px 15px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    margin-right: 5px;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.status-bar-safe-area {
    display: none;
    border-top: 1px solid #ccc;
    padding-top: 15px;
}

.padded-panel {
    background-color: #ffffff;
    border: 0px;
    padding: 8px;
}

@supports (-webkit-touch-callout: none) {
    .status-bar-safe-area {
        display: flex;
        position: sticky;
        top: 0;
        height: env(safe-area-inset-top);
        background-color: #f7f7f7;
        width: 100%;
        z-index: 1;
    }

    .flex-column, .navbar-brand {
        padding-left: env(safe-area-inset-left);
    }

    input:checked + .toggle-label {
        background-color: #53AF31;
    }
    /* Base styles with theme variables */
    body {
        color: var(--text-color);
        background-color: var(--background-color);
    }

    html, body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        font-family: Arial, sans-serif;
        margin: 0;
        font-weight: normal;
    }

    .rag-panel .radio-label input[type="radio"] {
        margin-right: 5px;
    }

    .rag-panel .radio-label span {
        font-size: 0.9em;
    }

    .rag-panel .inline-input-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .rag-panel .spinner-input-container {
        display: flex;
        align-items: center;
        position: relative;
    }

    .rag-panel .spinner-input {
        width: 60px;
        padding: 4px 6px;
        box-sizing: border-box;
        text-align: right;
        border: 1px solid #ccc;
        border-radius: 3px;
        font-size: 0.9em;
    }

    .rag-panel .spinner-buttons {
        display: flex;
        flex-direction: column;
        position: absolute;
        right: 3px;
        top: 1px;
        bottom: 1px;
        width: 15px;
    }

    .rag-panel .spinner-button {
        padding: 0;
        height: 100%;
    }

    a, .btn-link {
        color: var(--link-color);
    }
    /* Scrollbar customization */
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    ::-webkit-scrollbar-track {
        background: #f1f1f1;
    }

    ::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 4px;
    }

        ::-webkit-scrollbar-thumb:hover {
            background: #555;
        }
    /* Dark theme scrollbar */
    [data-theme='dark'] ::-webkit-scrollbar-track {
        background: #333;
    }

    [data-theme='dark'] ::-webkit-scrollbar-thumb {
        background: #666;
    }

        [data-theme='dark'] ::-webkit-scrollbar-thumb:hover {
            background: #888;
        }

    .tool-result-title {
        font-weight: bold;
        font-size: 0.9em;
        color: #555;
    }

    .tool-result-controls {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .tool-result-content {
        padding: 10px;
        overflow-x: auto;
        white-space: pre-wrap;
        font-family: monospace;
        font-size: 0.9em;
        /* max-height: 500px; - REMOVED: Allow unlimited height for testing with larger text blocks */
        overflow-y: auto;
    }

        .tool-result-content.collapsed {
            display: none;
        }

    .collapse-indicator {
        font-size: 0.8em;
        color: #777;
    }

    .state-indicator {
        font-size: 0.8em;
        font-weight: bold;
        padding: 2px 6px;
        border-radius: 3px;
    }

        .state-indicator.success {
            background-color: #d4edda;
            color: #155724;
        }

        .state-indicator.failed {
            background-color: #f8d7da;
            color: #721c24;
        }
    /* Phabricator Tickets styles */
    .unprocessed-task-card {
        transition: all 0.2s ease;
        cursor: pointer;
    }

        .unprocessed-task-card:hover {
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            transform: translateY(-1px);
        }

        .unprocessed-task-card.selected {
            border-color: #0d6efd !important;
            box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
        }

    .task-info-badge {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        font-size: 0.75rem;
    }

    .task-description-preview {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.4;
        height: 4.2em; /* 3 lines * 1.4 line-height */
    }

    .task-selection-badge {
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 10;
    }

    .phabricator-panel {
        margin-bottom: 1.5rem;
    }

    .email-source-badge {
        background-color: #e3f2fd;
        color: #1976d2;
        border: 1px solid #bbdefb;
    }

    .progress-overlay {
        position: relative;
    }

        .progress-overlay::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(255, 255, 255, 0.8);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10;
            border-radius: inherit;
        }

    .no-pending-tasks {
        text-align: center;
        padding: 2rem;
        color: #6c757d;
    }

    .task-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 1rem;
        margin-top: 1rem;
    }

    .task-card-body {
        padding: 1rem;
    }

    .task-meta {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 0.5rem;
        font-size: 0.875rem;
    }

    .task-email {
        color: #6c757d;
        font-size: 0.8rem;
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }

    .task-time {
        color: #6c757d;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    /* Agent name styling */
    .agent-name.clickable {
        color: var(--primary-color);
        cursor: pointer;
        padding: 2px 6px;
        border-radius: 4px;
        transition: all 0.2s ease;
        text-decoration: underline;
        text-decoration-color: transparent;
        border: 1px solid transparent;
        font-weight: 500;
    }
    
    .agent-name.clickable:hover {
        text-decoration-color: var(--primary-color);
        border-color: var(--primary-color);
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(83, 175, 49, 0.2);
    }
    
    .agent-name.clickable:active {
        background-color: var(--primary-color);
        color: white;
        text-decoration-color: white;
        transform: translateY(0);
        box-shadow: 0 1px 2px rgba(83, 175, 49, 0.3);
    }
    
    [data-theme='dark'] .agent-name.clickable:hover {
        box-shadow: 0 2px 4px rgba(83, 175, 49, 0.3);
    }
    
    [data-theme='dark'] .agent-name.clickable:active {
        background-color: var(--primary-color);
        color: white;
        text-decoration-color: white;
        transform: translateY(0);
        box-shadow: 0 1px 2px rgba(83, 175, 49, 0.3);
    }
    
    /* Sticky last user message styling - REMOVED: Feature no longer used */
    
    /* Tool result compact styles */
    .tool-compact-container {
        margin: 4px 0;
    }
    
    .tool-compact-line {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 4px 24px 4px 8px; /* Added right padding for collapse button */
        background-color: #f8f9fa;
        border: 1px solid #dee2e6;
        border-radius: 4px;
        font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
        font-size: 0.85em;
        cursor: pointer;
        transition: background-color 0.2s ease;
        min-height: 28px;
        position: relative; /* For absolute positioning of collapse button */
    }
    
    .tool-compact-line:hover {
        background-color: #e9ecef;
    }
    
    .tool-compact-line.processing {
        background-color: #fff3cd;
        border-color: #ffeaa7;
    }
    
    .tool-compact-line.success {
        background-color: #d1ecf1;
        border-color: #bee5eb;
    }
    
    .tool-compact-line.error {
        background-color: #f8d7da;
        border-color: #f5c6cb;
    }
    
    .tool-compact-name {
        font-weight: 600;
        color: #495057;
    }
    
    .tool-compact-args {
        color: #6c757d;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .tool-compact-status {
        font-weight: 500;
        min-width: 80px;
        text-align: right;
        color: #495057;
    }
    
    /* REMOVED: .tool-compact-toggle - now using consistent block-collapse-btn */
    
    .tool-expanded-content {
        border: 1px solid #dee2e6;
        border-top: none;
        border-radius: 0 0 4px 4px;
        background-color: white;
        padding: 12px;
    }
    
    .tool-result-section {
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid #eee;
    }
    
    .tool-result-header {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
    }
    
    .tool-result-content {
        background-color: #f8f9fa;
        border: 1px solid #dee2e6;
        border-radius: 4px;
        padding: 8px;
        font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
        font-size: 0.85em;
        white-space: pre-wrap;
        /* max-height: 300px; - REMOVED: Allow unlimited height for testing with larger text blocks */
        overflow-y: auto;
    }
    
    /* Dark theme styles */
    [data-theme='dark'] .tool-compact-line {
        background-color: #2a2a2a;
        border-color: #444;
    }
    
    [data-theme='dark'] .tool-compact-line:hover {
        background-color: #333;
    }
    
    [data-theme='dark'] .tool-compact-line.processing {
        background-color: #3a3520;
        border-color: #4a4226;
    }
    
    [data-theme='dark'] .tool-compact-line.success {
        background-color: #1f3a3a;
        border-color: #2a4545;
    }
    
    [data-theme='dark'] .tool-compact-line.error {
        background-color: #3a2020;
        border-color: #452626;
    }
    
    [data-theme='dark'] .tool-compact-name,
    [data-theme='dark'] .tool-compact-status {
        color: #e0e0e0;
    }
    
    [data-theme='dark'] .tool-compact-args {
        color: #ced4da;
    }
    
    [data-theme='dark'] .tool-expanded-content {
        background-color: #2a2a2a;
        border-color: #444;
    }
    
    [data-theme='dark'] .tool-result-section {
        border-top-color: #444;
    }
    
    [data-theme='dark'] .tool-result-content {
        background-color: #1a1a1a;
        border-color: #444;
        color: #e0e0e0;
    }
    
    /* DISABLED: Hide input during processing to free up space */
    /* .speech-to-text-container.hidden-during-processing {
        display: none !important;
        transition: all 0.3s ease;
    } */
    
    /* Expand chat messages when input is hidden */
    .chat-messages-container {
        transition: height 0.3s ease;
    }
    
    /* Processing indicator overlay for better UX */
    .processing-overlay {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
        color: white;
        padding: 16px 24px;
        font-size: 1rem;
        font-weight: 500;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 20px;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        backdrop-filter: blur(10px);
        border-top: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .processing-overlay.visible {
        transform: translateY(0);
    }
    
    .processing-overlay .spinner {
        animation: spin 1s linear infinite;
        font-size: 1.2em;
        color: rgba(255, 255, 255, 0.9);
    }
    
    .processing-overlay span {
        font-size: 1rem;
        font-weight: 500;
        letter-spacing: 0.3px;
        text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }
    
    .processing-overlay .btn {
        border: 2px solid rgba(255, 255, 255, 0.4);
        background: rgba(220, 53, 69, 0.8);
        color: white;
        transition: all 0.2s ease;
        font-size: 0.9em;
        padding: 6px 16px;
        font-weight: 600;
        border-radius: 6px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }
    
    .processing-overlay .btn:hover {
        background: rgba(220, 53, 69, 1);
        border-color: rgba(255, 255, 255, 0.6);
        color: white;
        transform: scale(1.05);
        box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    }
    
    .processing-overlay .btn:active {
        transform: scale(0.98);
        box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    }
    
    @keyframes spin {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }
    
    [data-theme='dark'] .processing-overlay {
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    
    /* Responsive processing overlay */
    @media (max-width: 768px) {
        .processing-overlay {
            padding: 12px 16px;
            gap: 15px;
            font-size: 0.9rem;
        }
        
        .processing-overlay .btn {
            font-size: 0.8rem;
            padding: 5px 12px;
        }
        
        .processing-overlay span {
            font-size: 0.9rem;
        }
        
        .processing-overlay .spinner {
            font-size: 1rem;
        }
    }
    
    @media (max-width: 480px) {
        .processing-overlay {
            flex-direction: column;
            gap: 10px;
            padding: 10px 12px;
        }
        
        .processing-overlay .btn {
            width: auto;
            min-width: 100px;
        }
    }
