/* Custom Styles for RequireWise BRD Agent */

:root {
    --color-bg-1: rgba(59, 130, 246, 0.08);  /* Blue */
    --color-bg-2: rgba(139, 92, 246, 0.08);  /* Purple */
    --color-bg-3: rgba(239, 68, 68, 0.08);   /* Red */
    --color-bg-4: rgba(34, 197, 94, 0.08);   /* Green */
}

body {
    background-color: #0f1115;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.05), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.05), transparent 25%);
}

/* Glassmorphism Utilities */
.glass-nav {
    background: rgba(15, 17, 21, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.glass-card {
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Bento Grid System */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1.5rem;
    padding: 1rem 0;
}

.bento-item {
    border-radius: 1.5rem;
    overflow: hidden;
}

.bento-large { grid-column: span 3; grid-row: span 2; }
.bento-wide { grid-column: span 3; grid-row: span 1; }
.bento-tall { grid-column: span 2; grid-row: span 2; }

/* Responsive Grid */
@media (max-width: 1024px) {
    .bento-grid { grid-template-columns: repeat(4, 1fr); }
    .bento-large { grid-column: span 4; grid-row: span 2; }
    .bento-wide { grid-column: span 4; grid-row: span 1; }
    .bento-tall { grid-column: span 2; grid-row: span 2; }
}

@media (max-width: 768px) {
    .bento-grid { grid-template-columns: repeat(1, 1fr); }
    .bento-large, .bento-wide, .bento-tall { grid-column: span 1; grid-row: auto; }
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

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

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Loader Animation */
.loader {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    display: inline-block;
    position: relative;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}
.loader::after {
    content: '';  
    box-sizing: border-box;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-bottom-color: #3b82f6;
}

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

/* Recording Animation */
.recording .record-icon {
    border-radius: 8px;
    transform: scale(0.6);
}

.recording .record-pulse {
    display: block;
}
/* ════════════════════════════════════════════
   PHASE 2: ADVANCED DASHBOARD STYLES
   ════════════════════════════════════════════ */

/* Dashboard Tab Navigation */
.dash-tab {
    color: rgba(156, 163, 175, 1);
    cursor: pointer;
    white-space: nowrap;
}
.dash-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.active-tab {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Conflict filter pills */
.conflict-filter {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(156,163,175,1);
    cursor: pointer;
    transition: all 0.2s;
}
.conflict-filter:hover { background: rgba(255,255,255,0.12); color: #fff; }
.active-filter { background: rgba(239,68,68,0.2) !important; color: #f87171 !important; border-color: rgba(239,68,68,0.4) !important; }

/* BRD section accordion */
.brd-section-header {
    cursor: pointer;
    user-select: none;
}
.brd-section-body {
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

/* Stakeholder sub-tabs */
.stakeholder-view-tab {
    color: rgba(156,163,175,1);
    cursor: pointer;
    white-space: nowrap;
}
.stakeholder-view-tab:hover { background: rgba(255,255,255,0.08); color: #fff; }
.active-stakeholder-tab {
    background: rgba(139,92,246,0.2) !important;
    color: #a78bfa !important;
    border: 1px solid rgba(139,92,246,0.3);
}

/* BRD view filter buttons */
.brd-view-btn { cursor: pointer; }

/* Severity badge colors */
.badge-critical { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-high     { background: rgba(249,115,22,0.15); color: #fb923c; border: 1px solid rgba(249,115,22,0.3); }
.badge-medium   { background: rgba(234,179,8,0.15);  color: #facc15; border: 1px solid rgba(234,179,8,0.3); }
.badge-low      { background: rgba(34,197,94,0.15);  color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }

/* Traceability status badges */
.status-approved     { background: rgba(34,197,94,0.15);  color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.status-in-progress  { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.status-under-review { background: rgba(234,179,8,0.15);  color: #facc15; border: 1px solid rgba(234,179,8,0.3); }
.status-pending      { background: rgba(156,163,175,0.15);color: #9ca3af; border: 1px solid rgba(156,163,175,0.3); }

/* D3 graph */
#kg-svg .kg-link { stroke-opacity: 0.5; }
#kg-svg .kg-link:hover { stroke-opacity: 1; }
#kg-svg .node-circle { cursor: pointer; stroke-width: 2; }
#kg-svg .node-circle:hover { filter: brightness(1.3); }
#kg-svg .node-label { font-size: 10px; fill: rgba(255,255,255,0.7); pointer-events: none; }

/* Sentiment bar */
.sentiment-bar {
    height: 6px;
    border-radius: 999px;
    background: rgba(255,255,255,0.05);
    overflow: hidden;
}
.sentiment-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 1s ease;
}

/* KPI card pulse */
@keyframes kpi-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
    70%  { box-shadow: 0 0 0 8px rgba(59,130,246,0.0); }
    100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.0); }
}
.kpi-pulse { animation: kpi-pulse 2s ease-out 0.5s 1; }

/* Conflict card expand arrow */
.conflict-toggle-icon { transition: transform 0.2s; }
.conflict-expanded .conflict-toggle-icon { transform: rotate(180deg); }

/* ════════════════════════════════════════════
   PHASE 3: PLAYGROUND & SETTINGS STYLES
   ════════════════════════════════════════════ */

/* Playground Cards */
.pg-card {
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
}
.pg-card:hover {
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-2px);
}
.pg-card.selected {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}

.pg-chat-card {
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
}
.pg-chat-card:hover {
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.05);
    transform: translateY(-2px);
}
.pg-chat-card.selected {
    border-color: rgba(139, 92, 246, 0.5);
    background: rgba(139, 92, 246, 0.1);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.15);
}

/* Line clamp utility */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* BRD Section Accordion (Playground) */
.brd-pg-section {
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    overflow: hidden;
    transition: border-color 0.2s ease;
}
.brd-pg-section:hover {
    border-color: rgba(255, 255, 255, 0.1);
}
.brd-pg-section-header {
    cursor: pointer;
    user-select: none;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
}
.brd-pg-section-header:hover {
    background: rgba(255, 255, 255, 0.04);
}
.brd-pg-section-body {
    display: none;
    padding: 0 1rem 1rem;
}
.brd-pg-section.open .brd-pg-section-body {
    display: block;
}
.brd-pg-chevron {
    transition: transform 0.2s ease;
    width: 1rem;
    height: 1rem;
    color: rgba(156, 163, 175, 1);
}
.brd-pg-section.open .brd-pg-chevron {
    transform: rotate(180deg);
}

/* Diff View */
.diff-line {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    margin: 0.125rem 0;
}
.diff-removed {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border-left: 3px solid rgba(239, 68, 68, 0.5);
}
.diff-added {
    background: rgba(34, 197, 94, 0.1);
    color: #86efac;
    border-left: 3px solid rgba(34, 197, 94, 0.5);
}
.diff-section-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: #60a5fa;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.diff-section-header:first-child {
    margin-top: 0;
    border-top: none;
}

/* Settings Modal */
.settings-panel {
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
#settings-modal:not(.hidden) .settings-panel {
    transform: scale(1);
    opacity: 1;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: all 0.3s ease;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
}
.toggle-switch input:checked + .toggle-slider {
    background: rgba(59, 130, 246, 0.5);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Expandable Error Toast */
.pg-error-toast {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    animation: slideDown 0.3s ease;
}
.pg-error-toggle {
    cursor: pointer;
    color: #f87171;
    font-size: 0.75rem;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
    margin-top: 0.5rem;
}
.pg-error-detail {
    display: none;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.5rem;
    font-family: monospace;
    font-size: 0.7rem;
    color: #fca5a5;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.pg-error-detail.open {
    display: block;
}

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

/* Sync Files button pulse */
@keyframes syncPulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.sync-active {
    animation: syncPulse 1s ease-out infinite;
}

/* BRD content formatting inside playground */
.pg-brd-content p { margin-bottom: 0.5rem; }
.pg-brd-content strong { color: #e5e7eb; }
.pg-brd-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
}
.pg-brd-content table th,
.pg-brd-content table td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    text-align: left;
}
.pg-brd-content table th {
    background: rgba(255, 255, 255, 0.05);
    color: #d1d5db;
    font-weight: 600;
}