/* ============================================
   SynerComm Purple Team Platform - Main Styles
   Dark theme matching CASM visual identity
   ============================================ */

/* --- CSS Variables --- */
:root {
    /* Colors - matched from CASM */
    --bg-primary: #1a1a1a;
    --bg-secondary: #222222;
    --bg-tertiary: #2a2a2a;
    --bg-card: #2d2d2d;
    --bg-input: #1a1a1a;
    --bg-hover: #333333;

    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;

    --accent: #c8864a;
    --accent-hover: #d9975b;
    --accent-muted: rgba(200, 134, 74, 0.15);

    --border: #3a3a3a;
    --border-light: #444444;

    /* Status colors */
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --info: #2196f3;

    /* Sizing */
    --sidebar-width: 220px;
    --topbar-height: 56px;
    --border-radius: 4px;

    /* Font */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
}

/* --- Loading Bar --- */
.loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--accent);
    z-index: 9999;
    transition: width 0.3s ease;
    opacity: 0;
}

.loading-bar.active {
    opacity: 1;
    animation: loading-progress 2s ease-in-out infinite;
}

@keyframes loading-progress {
    0% { width: 0; }
    50% { width: 70%; }
    100% { width: 90%; }
}

.loading-bar.done {
    width: 100%;
    opacity: 0;
    transition: width 0.1s, opacity 0.3s 0.1s;
}

/* --- Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

/* --- App Layout --- */
.app-layout {
    display: flex;
    height: 100vh;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-logo {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo img {
    width: 100%;
    height: auto;
    flex: 1;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    color: var(--text-primary);
}

/* Collapsed sidebar */
.sidebar-collapsed {
    width: 56px;
}

.sidebar-collapsed .sidebar-logo img {
    display: none;
}

.sidebar-collapsed .nav-item span {
    display: none;
}

.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px;
}

.sidebar-collapsed .nav-item.active {
    padding-left: 10px;
    border-left: 3px solid var(--accent);
    padding-left: 7px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 8px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--accent);
    background: var(--accent-muted);
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
}

.page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 6px 12px;
    color: var(--text-primary);
    font-size: 13px;
    width: 240px;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.user-name {
    color: var(--text-secondary);
    font-size: 13px;
}

.tz-badge {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    cursor: help;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 20px;
}

/* --- Tables --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-family);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

/* --- Status Pills --- */
.status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-pill--success { background: rgba(76, 175, 80, 0.15); color: var(--success); }
.status-pill--warning { background: rgba(255, 152, 0, 0.15); color: var(--warning); }
.status-pill--error   { background: rgba(244, 67, 54, 0.15); color: var(--error); }
.status-pill--info    { background: rgba(33, 150, 243, 0.15); color: var(--info); }
.status-pill--neutral { background: rgba(160, 160, 160, 0.15); color: var(--text-secondary); }

/* --- Tags --- */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}

.tag--orange  { background: rgba(200, 134, 74, 0.2); color: var(--accent); }
.tag--blue    { background: rgba(33, 150, 243, 0.2); color: var(--info); }
.tag--green   { background: rgba(76, 175, 80, 0.2); color: var(--success); }

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: var(--error);
}

.alert-success {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: var(--success);
}

.alert-mfa {
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid rgba(255, 152, 0, 0.3);
    color: var(--warning);
}

/* --- Login Page --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 0 20px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img {
    height: 48px;
}

.login-subtitle {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 15px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 32px;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 20px;
}

.login-card .btn-primary {
    margin-top: 8px;
}

/* --- Dashboard Placeholder --- */
.dashboard-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-secondary);
}

.dashboard-placeholder h1 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 600;
}

.page-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.meta-text {
    color: var(--text-secondary);
    font-size: 13px;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 13px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* --- Form Layout --- */
.form-row {
    display: flex;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* --- Detail Grid --- */
.detail-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-grid .card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.card-row {
    display: flex;
    gap: 16px;
}

/* --- MITRE Search --- */
.mitre-search-container {
    position: relative;
}

.mitre-results {
    position: relative;
}

.mitre-dropdown {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    max-height: 250px;
    overflow-y: auto;
    margin-top: 4px;
}

.mitre-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.mitre-option:hover {
    background: var(--bg-hover);
}

.mitre-option.mitre-sub {
    padding-left: 24px;
    color: var(--text-secondary);
}

.mitre-option strong {
    color: var(--accent);
    margin-right: 4px;
}

/* --- Small Button --- */
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* --- Admin Tabs --- */
.admin-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.admin-tab {
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.admin-tab:hover {
    color: var(--text-primary);
}

.admin-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* --- Timeline --- */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.timeline-event {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.timeline-event:last-child {
    border-bottom: none;
}

.timeline-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.timeline-time {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent);
    font-weight: 600;
}

.timeline-body {
    color: var(--text-primary);
    font-size: 14px;
    padding-left: 2px;
    white-space: pre-wrap;
}

.timeline-evidence {
    margin-top: 6px;
    padding-left: 2px;
}

.evidence-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.evidence-link {
    font-size: 12px;
}

.evidence-thumbnail {
    max-width: 200px;
    max-height: 120px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    margin-top: 4px;
    cursor: pointer;
}

.evidence-thumbnail:hover {
    border-color: var(--accent);
}

/* --- Evidence Text Viewer --- */
.evidence-text-viewer {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 16px;
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination-link {
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
}

.pagination-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination-current {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pagination-ellipsis {
    padding: 6px 8px;
    color: var(--text-muted);
}

/* --- Playbook Builder --- */
.builder-tactic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.builder-techniques {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.builder-technique {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 13px;
}

.builder-technique:hover {
    background: var(--bg-hover);
}

.builder-technique-info {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-size: 13px;
}

.breadcrumb-link {
    color: var(--text-muted);
}

.breadcrumb-link:hover {
    color: var(--accent);
}

.breadcrumb-sep {
    color: var(--text-muted);
}

.breadcrumb-current {
    color: var(--text-secondary);
}

/* --- Detection Expectations --- */
.detection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 10px;
}

.detection-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detection-list {
    list-style: none;
    padding: 0;
    margin: 6px 0 0 0;
}

.detection-list li {
    padding: 3px 0;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.detection-list li:last-child {
    border-bottom: none;
}

.builder-mitre-id {
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 12px;
    min-width: 80px;
}

.evidence-text-viewer pre {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.timeline-actions {
    margin-top: 6px;
}

.evidence-upload-toggle {
    font-size: 13px;
}

.evidence-upload-toggle summary {
    cursor: pointer;
    list-style: none;
}

.evidence-form {
    margin-top: 8px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.file-input {
    font-size: 13px;
    color: var(--text-secondary);
}

/* --- Metrics Grid --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.metric-value--good { color: var(--success); }
.metric-value--warn { color: var(--warning); }
.metric-value--bad  { color: var(--error); }

.metric-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
}

.metric-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s;
}

.metric-bar--green .metric-bar-fill,
.metric-bar--green {
    background: var(--success);
}

.metric-bar--blue .metric-bar-fill,
.metric-bar--blue {
    background: var(--info);
}

.metric-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* --- MITRE Tactic Grid --- */
.tactic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.tactic-cell {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 12px;
}

/* --- Timing Bar --- */
.timing-bar {
    display: flex;
    align-items: center;
    gap: 0;
    height: 24px;
    font-size: 10px;
}

.timing-marker {
    padding: 2px 4px;
    font-weight: 700;
    border-radius: 2px;
    white-space: nowrap;
    flex-shrink: 0;
}

.timing-attack { background: var(--error); color: #fff; }
.timing-detect { background: var(--success); color: #fff; }
.timing-alert { background: var(--info); color: #fff; }
.timing-prevent { background: var(--info); color: #fff; }
.timing-respond { background: var(--warning); color: #fff; }

.timing-segment {
    height: 4px;
    position: relative;
    min-width: 20px;
}

.timing-seg-detect { background: rgba(244, 67, 54, 0.3); }
.timing-seg-alert { background: rgba(33, 150, 243, 0.3); }
.timing-seg-prevent { background: rgba(33, 150, 243, 0.3); }
.timing-seg-respond { background: rgba(255, 152, 0, 0.3); }

.timing-label {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
}

.tactic-cell.tactic-tested {
    border-color: var(--accent);
}

.tactic-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.tactic-id {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.tactic-stats {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* --- App Footer --- */
.app-footer {
    display: flex;
    justify-content: space-between;
    padding: 8px 24px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* --- Sortable Headers --- */
.sort-header {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.sort-header:hover {
    color: var(--accent);
}

.sort-header.sort-active {
    color: var(--accent);
}

/* --- Report Brand --- */
.report-brand {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* --- MITRE Browser Layout --- */
.mitre-layout {
    display: flex;
    gap: 16px;
}

.mitre-sidebar {
    width: 220px;
    flex-shrink: 0;
}

.mitre-sidebar h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.mitre-tactic-link {
    display: block;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 2px;
}

.mitre-tactic-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mitre-tactic-link.active {
    background: var(--accent-muted);
    color: var(--accent);
}

.mitre-tactic-id {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-right: 4px;
}

.mitre-content {
    flex: 1;
    min-width: 0;
}

/* --- WebSocket Status --- */
.ws-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.ws-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.ws-connected::before { background: var(--success); }
.ws-disconnected::before { background: var(--warning); }
.ws-error::before { background: var(--error); }

.ws-label { font-weight: 600; }
.ws-count { color: var(--text-muted); }

/* --- Toast Notifications --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-left: 3px solid var(--accent);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--border-radius);
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: toast-in 0.3s ease;
}

.toast-fade {
    opacity: 0;
    transition: opacity 0.3s;
}

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
