/**
 * QL-Dash Component Styles
 * Consolidated CSS for reusable UI components
 */

/* ============================================
   TABLES
   ============================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

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

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

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

.data-table tbody tr:hover {
    background: var(--panel-2);
}

.data-table .text-right {
    text-align: right;
}

.data-table .text-center {
    text-align: center;
}

/* Compact table variant */
.data-table.compact th,
.data-table.compact td {
    padding: 8px 12px;
    font-size: 13px;
}

/* ============================================
   METRIC CARDS
   ============================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.metric-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.metric-value.positive,
.metric-value.pnl-positive {
    color: var(--green);
}

.metric-value.negative,
.metric-value.pnl-negative {
    color: var(--red);
}

/* Small metric variant */
.metric-card.small {
    padding: 12px;
}

.metric-card.small .metric-label {
    font-size: 10px;
}

.metric-card.small .metric-value {
    font-size: 16px;
}

/* ============================================
   P&L COLORS
   ============================================ */
.pnl-positive {
    color: var(--green) !important;
    font-weight: 600;
}

.pnl-negative {
    color: var(--red) !important;
    font-weight: 600;
}

.pnl-neutral {
    color: var(--muted);
}

/* ============================================
   CHIPS / BADGES
   ============================================ */
.chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.chip.buy,
.chip.positive,
.chip.success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid var(--green);
    color: var(--green);
}

.chip.sell,
.chip.negative,
.chip.danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--red);
    color: var(--red);
}

.chip.neutral,
.chip.info {
    background: rgba(96, 165, 250, 0.15);
    border: 1px solid var(--blue);
    color: var(--blue);
}

.chip.warning {
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid #fbbf24;
    color: #fbbf24;
}

.chip.muted {
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--line);
    border-top: 3px solid var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.loading-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.loading-subtitle {
    font-size: 13px;
    color: var(--muted);
}

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

/* ============================================
   ALERTS / ERROR BANNERS
   ============================================ */
.alert {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

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

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-message {
    font-size: 14px;
    opacity: 0.9;
}

.alert.error,
.alert.danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--red);
    color: var(--red);
}

.alert.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--green);
    color: var(--green);
}

.alert.warning {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid #fbbf24;
    color: #fbbf24;
}

.alert.info {
    background: rgba(96, 165, 250, 0.1);
    border: 1px solid var(--blue);
    color: var(--blue);
}

/* Legacy error banner support */
.error-banner {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--red);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    color: var(--red);
}

/* ============================================
   MODALS
   ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius, 16px);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    font-size: 20px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

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

.form-group .help-text {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

.form-group.error input,
.form-group.error select {
    border-color: var(--red);
}

.form-group .error-text {
    font-size: 12px;
    color: var(--red);
    margin-top: 6px;
}

/* ============================================
   PERIOD TABS (for charts)
   ============================================ */
.period-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.period-tab {
    padding: 8px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.period-tab:hover {
    border-color: var(--blue);
    color: var(--text);
}

.period-tab.active {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

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

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

.empty-state-message {
    font-size: 14px;
    max-width: 300px;
    margin: 0 auto;
}

/* ============================================
   SKELETON LOADING
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 50%, var(--panel) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-box {
    height: 100px;
    border-radius: 12px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
