/**
 * Application UI Styles
 * Reusable components for app windows: cards, tables, badges, grids, etc.
 */

/* Card Component */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s;
}

.card:hover {
    border-color: var(--primary);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

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

.card-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.card-body {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.card-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Badge Component */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.success {
    background: rgba(0, 255, 170, 0.2);
    color: var(--success);
    border: 1px solid var(--success);
}

.badge.warning {
    background: rgba(255, 170, 0, 0.2);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.badge.error {
    background: rgba(255, 85, 85, 0.2);
    color: var(--error);
    border: 1px solid var(--error);
}

.badge.info {
    background: rgba(85, 170, 255, 0.2);
    color: var(--info);
    border: 1px solid var(--info);
}

.badge.neutral {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Table Component */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table thead {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}

.table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.table tbody tr:hover {
    background: var(--bg-surface);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* List Component */
.list {
    list-style: none;
}

.list-item {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.list-item:hover {
    background: var(--bg-surface);
}

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

.list-item-icon {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.list-item-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.list-item-actions {
    display: flex;
    gap: 8px;
}

/* Grid Component */
.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-auto {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* Stats Box */
.stats-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stats-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}

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

.stats-change {
    font-size: 12px;
    margin-top: 8px;
    font-weight: 600;
}

.stats-change.positive {
    color: var(--success);
}

.stats-change.negative {
    color: var(--error);
}

/* Graph Placeholder */
.graph-placeholder {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.graph-placeholder::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: linear-gradient(to top, var(--primary), transparent);
    opacity: 0.1;
    clip-path: polygon(
        0% 100%, 10% 70%, 20% 75%, 30% 50%, 40% 55%,
        50% 30%, 60% 45%, 70% 40%, 80% 60%, 90% 50%, 100% 70%,
        100% 100%
    );
}

/* Sidebar Layout */
.sidebar-layout {
    display: flex;
    height: 100%;
}

.sidebar {
    width: 240px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.sidebar-section {
    padding: 20px 16px 8px;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.sidebar-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}

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

.sidebar-item.active {
    background: var(--bg-window);
    color: var(--primary);
    font-weight: 500;
}

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

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

.form-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-input::placeholder {
    color: var(--text-dim);
}

.form-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
}

.btn:hover {
    border-color: var(--primary);
    background: var(--bg-surface-hover);
}

.btn:active {
    transform: scale(0.95);
}

.btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #000;
}

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

.btn.danger {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.btn.small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Code Block */
.code-block {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
    color: var(--primary-light);
    overflow-x: auto;
    line-height: 1.6;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state-text {
    font-size: 14px;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    gap: 4px;
}

.tab {
    padding: 12px 20px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

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

.tab-content {
    padding: 20px 0;
}

/* Chaos Inbox */
.chaos-inbox .two-column-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.chaos-meta { display: flex; justify-content: space-between; color: var(--text-secondary); font-size: 12px; }
.chaos-body { margin: 8px 0; color: var(--text-primary); }
.chaos-tags { color: var(--text-secondary); font-size: 12px; }
.chaos-filters { margin-bottom: 12px; }
.chaos-clusters .pill { margin-right: 6px; display: inline-block; padding: 4px 6px; }

/* Identity Center */
.identity-center .identity-row { display: grid; grid-template-columns: 1fr 2fr; padding: 6px 0; }
.identity-center .label { color: var(--text-secondary); }
.identity-howto { padding-left: 18px; line-height: 1.5; }

/* Creator Studio */
.creator-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.creator-body p { margin: 0 0 8px 0; }
.creator-assets ul { padding-left: 18px; }

/* Compliance & Ops */
.compliance-ops { display: flex; flex-direction: column; gap: 12px; }
