/* ==========================================================================
   AgenticApp - Component Styles
   Reusable component classes for consistent UI patterns
   ========================================================================== */

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */

/* Agent Card - List view card for agents */
.agent-card {
    height: 100%;
}

.agent-card .card-title {
    margin-bottom: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.agent-card .card-text {
    font-size: 0.875rem;
}

/* Stats Card - Metric display cards */
.stats-card {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    background: white;
    border-radius: 0.5rem;
    border: 1px solid #e0e0e0;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    gap: 1rem;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.stats-card .stats-icon {
    font-size: 2rem;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: rgba(0, 123, 255, 0.1);
    flex-shrink: 0;
}

.stats-card .stats-icon.text-primary {
    background: rgba(0, 123, 255, 0.1);
    color: #007bff;
}

.stats-card .stats-icon.text-success {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.stats-card .stats-icon.text-info {
    background: rgba(23, 162, 184, 0.1);
    color: #17a2b8;
}

.stats-card .stats-icon.text-warning {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.stats-card .stats-content {
    flex: 1;
}

.stats-card .stats-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stats-card .stats-label {
    font-size: 0.875rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Legacy stats card styles for backward compatibility */
.stats-card h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0;
}

.stats-card h6 {
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

/* Info Card - General information card */
.info-card {
    margin-top: 1rem;
}

.info-card .card-header h5 {
    margin-bottom: 0;
    font-size: 1rem;
    font-weight: 600;
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */

/* Form Section - Grouping related form fields */
.form-section {
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
    margin-bottom: 1.5rem;
}

.form-section h5 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #495057;
}

/* Form Group Spacing */
.form-group-spaced {
    margin-bottom: 1.5rem;
}

/* Required Field Indicator */
.field-required {
    color: #dc3545;
    font-weight: 600;
}

/* ==========================================================================
   BADGES & STATUS INDICATORS
   ========================================================================== */

/* Status Badge Group */
.status-badge-group {
    display: flex;
    gap: 0.25rem;
}

/* Active/Inactive Badges */
.badge-active {
    background-color: #28a745;
}

.badge-inactive {
    background-color: #6c757d;
}

/* Shared/Private Badges */
.badge-shared {
    background-color: #17a2b8;
}

.badge-private {
    background-color: #007bff;
}

/* ==========================================================================
   BUTTONS & ACTIONS
   ========================================================================== */

/* Action Toolbar - Button groups for actions */
.action-toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Button Group Full Width */
.btn-group-full {
    width: 100%;
}

/* Icon Button - Buttons with icons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* Back Button */
.btn-back {
    padding: 0;
    font-size: 1.5rem;
    color: #6c757d;
    background: none;
    border: none;
}

.btn-back:hover {
    color: #495057;
}

/* ==========================================================================
   MODALS & OVERLAYS
   ========================================================================== */

/* Modal Backdrop - Semi-transparent overlay */
.modal-backdrop-custom {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}

/* Confirmation Modal */
.modal-confirm .modal-body {
    padding: 1.5rem;
}

.modal-confirm .modal-footer {
    padding: 1rem 1.5rem;
}

/* ==========================================================================
   LOADING & STATES
   ========================================================================== */

/* Loading State - Centered spinner */
.loading-state {
    text-align: center;
    padding: 3rem 1rem;
}

.loading-state .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* Empty State - No data message */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state i {
    font-size: 3rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

.empty-state p {
    color: #6c757d;
    font-size: 1.125rem;
}

/* Error State - Error message display */
.error-state {
    padding: 1rem;
    border-radius: 0.375rem;
}

/* ==========================================================================
   PAGE HEADERS
   ========================================================================== */

/* Page Header - Top of page with title and actions */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h3 {
    margin-bottom: 0;
    font-size: 1.75rem;
    font-weight: 600;
}

/* Page Header with Back Button */
.page-header-with-back {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header-with-back h3 {
    margin-bottom: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

/* ==========================================================================
   LISTS & ITEMS
   ========================================================================== */

/* Tool List - List of tools with icons */
.tool-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tool-list li {
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-list li i {
    color: #6c757d;
}

/* Definition List Horizontal */
.dl-horizontal dt {
    font-weight: 600;
    color: #495057;
}

.dl-horizontal dd {
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   GRID & LAYOUT
   ========================================================================== */

/* Stats Grid - Grid layout for statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* Card Grid - Grid layout for cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* ==========================================================================
   CHAT INTERFACE - Full viewport, single column, compact design
   ========================================================================== */

/* Chat Page - Full viewport minus navbar, no scrollbars */
.chat-page {
    /* Compensate for workspace-content padding */
    margin: -24px;
    height: calc(100vh - 70px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========== CONVERSATION PANEL ========== */
.chat-conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

/* Chat Header - Agent selector + compact metrics */
.chat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #dee2e6;
    background: white;
    flex-shrink: 0;
}

/* Agent Selector */
.chat-agent-selector {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-agent-dropdown {
    min-width: 200px;
    max-width: 300px;
    padding: 0.375rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
}

.chat-agent-dropdown:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Loading/error states */
.chat-loading-text {
    margin-left: 0.5rem;
    font-size: 0.875rem;
}

.chat-error-text {
    color: #dc3545;
    font-size: 0.875rem;
}

.chat-new-conversation {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Compact Metrics (right-aligned) */
.chat-metrics-compact {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    font-size: 0.75rem;
}

.chat-metric-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chat-metric-label {
    color: #6c757d;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.125rem;
}

.chat-metric-value {
    font-weight: 600;
    color: #212529;
    font-size: 0.875rem;
}

.chat-metric-value.cost {
    color: #007bff;
}

/* Context usage with progress bar */
.chat-metric-item.context-usage {
    min-width: 120px;
}

.context-bar {
    position: relative;
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.context-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: #28a745;
    transition: width 0.3s ease, background-color 0.3s ease;
    border-radius: 10px;
}

.context-fill.warning {
    background: #ffc107;
}

.context-fill.critical {
    background: #dc3545;
}

.context-percent {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    font-weight: 600;
    color: #212529;
    z-index: 1;
}

/* Mobile: Stack metrics vertically, smaller text */
@media (max-width: 992px) {
    .chat-metrics-compact {
        gap: 1rem;
    }
    
    .chat-metric-label {
        font-size: 0.6rem;
    }
    
    .chat-metric-value {
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .chat-header {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.625rem 0.75rem;
    }
    
    .chat-agent-selector {
        width: 100%;
    }
    
    .chat-agent-dropdown {
        flex: 1;
        min-width: 0;
    }
    
    .chat-metrics-compact {
        width: 100%;
        justify-content: space-between;
        gap: 0.75rem;
    }
    
    .chat-metric-item {
        align-items: center;
    }
    

}

/* ========== MESSAGES AREA ========== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    background: #fafafa;
}

/* Empty state */
.chat-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    text-align: center;
    gap: 1rem;
}

.chat-empty i {
    font-size: 3rem;
    color: #dee2e6;
}

.chat-empty p {
    margin: 0;
    font-size: 1rem;
}

/* Messages */
.chat-message {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.agent {
    align-items: flex-start;
}

.chat-message-bubble {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    position: relative;
}

.chat-message.user .chat-message-bubble {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.chat-message.agent .chat-message-bubble {
    background: white;
    color: #212529;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 0.25rem;
}

.chat-message-meta {
    font-size: 0.7rem;
    color: #6c757d;
    margin-top: 0.25rem;
    padding: 0 0.25rem;
}

.chat-message.user .chat-message-meta {
    text-align: right;
}

.chat-message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
}

/* Tool invocations */
.chat-tool {
    padding: 0.5rem 1rem;
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    background: #f8f9fa;
    border-left: 3px solid #6c757d;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #6c757d;
}

.chat-tool.in-progress {
    border-left-color: #007bff;
    animation: pulse 1.5s ease-in-out infinite;
}

.chat-tool.completed {
    opacity: 0.7;
}

.chat-tool.failed {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.chat-tool .dots {
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60% { content: '...'; }
    80%, 100% { content: '....'; }
}

/* Mobile: Wider message bubbles */
@media (max-width: 767px) {
    .chat-message-bubble {
        max-width: 85%;
        padding: 0.625rem 0.875rem;
    }
    
    .chat-messages {
        padding: 0.75rem;
    }
}

/* ========== INPUT AREA ========== */
.chat-input {
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    background: white;
}

.chat-input-error {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
}

.chat-input-controls {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input-field {
    flex: 1;
    min-height: 42px;
    max-height: 200px;
    resize: none;
    padding: 0.625rem 0.875rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
}

.chat-input-field:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.chat-input-button {
    flex-shrink: 0;
    min-width: 90px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    border: none;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-input-button.send {
    background: #007bff;
    color: white;
}

.chat-input-button.send:hover:not(:disabled) {
    background: #0056b3;
}

.chat-input-button.stop {
    background: #dc3545;
    color: white;
}

.chat-input-button.stop:hover {
    background: #c82333;
}

.chat-input-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile: Adjust input area */
@media (max-width: 767px) {
    .chat-input {
        padding: 0.75rem;
    }
    
    .chat-input-field {
        font-size: 16px; /* Prevent iOS zoom */
    }
    
    .chat-input-button {
        min-width: 70px;
        font-size: 0.8rem;
    }
}

/* ========== SCROLLBAR STYLING ========== */
.chat-messages::-webkit-scrollbar,
.chat-agent-list::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.chat-agent-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb,
.chat-agent-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.chat-agent-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ==========================================================================
   UTILITIES
   ========================================================================== */

/* Text Utilities */
.text-muted-light {
    color: #adb5bd !important;
}

.text-uppercase-spaced {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Spacing Utilities */
.gap-sm {
    gap: 0.5rem;
}

.gap-md {
    gap: 1rem;
}

.gap-lg {
    gap: 1.5rem;
}

/* Border Utilities */
.border-light-gray {
    border: 1px solid #dee2e6;
}

/* Shadow Utilities */
.shadow-sm-hover:hover {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.shadow-hover:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   CONVERSATIONS
   ========================================================================== */

/* Conversation Messages Container */
.conversation-messages {
    max-height: 70vh;
    overflow-y: auto;
    padding: 1rem;
}

/* Individual Message Item */
.message-item {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid transparent;
}

/* User Message */
.message-item.user {
    background-color: #e3f2fd;
    border-left-color: #2196f3;
}

/* Assistant Message */
.message-item.assistant {
    background-color: #f3e5f5;
    border-left-color: #9c27b0;
}

/* System/Other Message */
.message-item:not(.user):not(.assistant) {
    background-color: #f5f5f5;
    border-left-color: #9e9e9e;
}

/* Message Header */
.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.message-role {
    font-size: 0.875rem;
    color: #495057;
}

.message-timestamp {
    font-size: 0.75rem;
}

/* Message Content */
.message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
    color: #212529;
}

/* Conversation Card */
.conversation-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.conversation-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Hover Lift Effect - Cards that lift on hover */
.hover-lift {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15) !important;
}

/* ==========================================================================
   CONVERSATION METRICS PANEL
   ========================================================================== */

/* Metrics Panel - Real-time conversation metrics display */
.metrics-panel {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: center;
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-label {
    font-size: 0.875rem;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.metric-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: #212529;
}

.metric-value.cost {
    color: #007bff;
    font-size: 1.125rem;
    font-weight: 600;
}

/* Progress Bar Container */
.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-bar-custom {
    flex: 1;
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    transition: width 0.5s ease, background-color 0.3s ease;
    border-radius: 5px;
}

/* Usage Color Classes */
.progress-fill.usage-low {
    background: linear-gradient(90deg, #28a745, #34ce57);
}

.progress-fill.usage-medium {
    background: linear-gradient(90deg, #ffc107, #ffcd38);
}

.progress-fill.usage-high {
    background: linear-gradient(90deg, #fd7e14, #ff922b);
}

.progress-fill.usage-critical {
    background: linear-gradient(90deg, #dc3545, #e4606d);
    animation: pulse-critical 2s ease-in-out infinite;
}

@keyframes pulse-critical {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Alert Adjustments for Metrics Panel */
.metrics-panel .alert {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .action-toolbar {
        width: 100%;
    }

    .action-toolbar .btn {
        flex: 1;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .metric-value.cost {
        font-size: 1rem;
    }


}
