/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Legacy variable names are now aliased onto the design-tokens.css
   palette so existing .portal-* and .app-* selectors pick up the new
   colours without a sweeping rewrite. The Catppuccin-Mocha hex values
   that used to live here have moved into design-tokens.css.
   Keep these aliases until every page is on ds-* primitives, then drop. */

/* app.css is the editor / app-shell layout. Portal pages get a separate
   stylesheet (portal.css) and own their own scrolling behaviour, so we
   only force the trapped editor layout when a page actually uses
   .app-layout. */
body { font-family: var(--font-sans); font-size: 14px; background: var(--bg-base); color: var(--text-primary); }
body:has(.app-layout) { height: 100%; overflow: hidden; }

/* App Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    background: var(--accent);
    color: var(--bg-primary);
    font-weight: 700;
    font-size: 13px;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    height: var(--toolbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 12px;
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.toolbar-input {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font-mono);
    width: 360px;
    outline: none;
    transition: border-color 0.15s;
}

.toolbar-input:focus {
    border-color: var(--accent);
}

.toolbar-input-short {
    width: 200px;
}

/* Buttons */
.btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
    font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-small {
    padding: 2px 8px;
    font-size: 12px;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--bg-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Content Panels */
.content-panels {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
}

.panel:last-child {
    border-right: none;
}

.panel-sidebar {
    width: 220px;
    min-width: 180px;
    flex-shrink: 0;
}

.panel-editor {
    flex: 1;
    min-width: 300px;
}

.panel-results {
    width: 420px;
    min-width: 300px;
    flex-shrink: 0;
}

.panel-header {
    height: 36px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.panel-header-actions {
    display: flex;
    gap: 4px;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Rule List */
.rule-list {
    list-style: none;
    padding: 4px 0;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s;
    color: var(--text-secondary);
}

.rule-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.rule-item.active {
    background: var(--bg-active);
    color: var(--text-primary);
    border-left: 2px solid var(--accent);
    padding-left: 10px;
}

.rule-icon {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    background: var(--bg-surface);
    color: var(--text-muted);
}

.rule-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Editor */
.editor-body {
    display: flex;
    flex-direction: column;
}

.editor-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.line-numbers {
    width: 48px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 10px 0;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-muted);
    overflow: hidden;
    user-select: none;
    flex-shrink: 0;
}

.line-number {
    padding-right: 12px;
    height: 20.8px;
}

.code-editor {
    flex: 1;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
}

.code-editor::placeholder {
    color: var(--text-muted);
}

/* Validation Bar */
.validation-bar {
    padding: 6px 12px;
    font-size: 12px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.validation-success {
    background: rgba(166, 227, 161, 0.1);
    color: var(--success);
}

.validation-error {
    background: rgba(243, 139, 168, 0.1);
    color: var(--error);
}

/* Results */
.result-stats {
    display: flex;
    gap: 4px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-severity-summary {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.severity-count {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.severity-error {
    background: rgba(243, 139, 168, 0.15);
    color: var(--error);
}

.severity-warning {
    background: rgba(250, 179, 135, 0.15);
    color: var(--warning);
}

.severity-info {
    background: rgba(137, 180, 250, 0.15);
    color: var(--info);
}

.result-summary-badge {
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
}

.result-error {
    padding: 12px;
    color: var(--error);
    font-size: 13px;
    background: rgba(243, 139, 168, 0.08);
}

/* Violations Table */
.violations-table-container {
    overflow-y: auto;
    flex: 1;
}

.violations-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.violations-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.violations-table th {
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.violations-table td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(49, 50, 68, 0.5);
    vertical-align: top;
}

.violation-row:hover {
    background: var(--bg-hover);
}

.violation-row.severity-error td:first-child {
    border-left: 2px solid var(--error);
}

.violation-row.severity-warning td:first-child {
    border-left: 2px solid var(--warning);
}

.violation-row.severity-info td:first-child {
    border-left: 2px solid var(--info);
}

.col-severity {
    width: 28px;
    text-align: center;
}

.severity-icon {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11px;
}

.severity-error .severity-icon { color: var(--error); }
.severity-warning .severity-icon { color: var(--warning); }
.severity-info .severity-icon { color: var(--info); }

.col-rule {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-entity {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 11px;
}

.entity-kind {
    display: inline-block;
    font-size: 9px;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 1px 4px;
    border-radius: 2px;
    margin-right: 4px;
    letter-spacing: 0.3px;
}

.col-file {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 120px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
    line-height: 1.6;
}

.no-violations {
    color: var(--success);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
