/* ============================================
   SQL Monitor Dashboard - Styles
   Uses design tokens from design-tokens.css
   ============================================ */

.sql-monitor-page {
    padding: var(--space-6);
    max-width: 1600px;
    margin: 0 auto;
}

/* ========== Header ========== */
.sql-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.sql-header h1 {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sql-header-controls {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.refresh-select {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

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

.refresh-btn {
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

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

.refresh-btn.loading .refresh-icon {
    animation: spin 1s linear infinite;
}

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

.last-update {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* ========== Overview Cards ========== */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.overview-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.overview-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
    opacity: 0.7;
}

.overview-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.overview-card .card-icon {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-2);
}

.overview-card .card-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.overview-card .card-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.overview-card.status-ok::before { background: var(--color-success); }
.overview-card.status-warning::before { background: var(--color-warning); }
.overview-card.status-danger::before { background: var(--color-error); }

/* ========== Server Info Badge ========== */
.server-info-bar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-5);
    margin-bottom: var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-5);
    flex-wrap: wrap;
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-xs);
}

.server-info-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-secondary);
}

.server-info-item strong {
    color: var(--text-primary);
}

.server-info-item .info-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success);
    display: inline-block;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ========== Panels Grid ========== */
.panels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}

.panels-grid.single-col {
    grid-template-columns: 1fr;
}

@media (max-width: 1200px) {
    .panels-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== Panel ========== */
.sql-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition-fast);
}

.sql-panel:hover {
    box-shadow: var(--shadow-md);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
    background: var(--hover-bg);
}

.panel-header h2 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
}

.panel-badge {
    font-size: var(--font-size-xs);
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-medium);
    line-height: 1;
}

.panel-badge.badge-info {
    background: var(--color-info-light);
    color: var(--color-info-dark);
}

.panel-badge.badge-warning {
    background: var(--color-warning-light);
    color: var(--color-warning-dark);
}

.panel-badge.badge-danger {
    background: var(--color-error-light);
    color: var(--color-error-dark);
}

.panel-badge.badge-success {
    background: var(--color-success-light);
    color: var(--color-success-dark);
}

.panel-body {
    padding: var(--space-4) var(--space-5);
    max-height: 450px;
    overflow-y: auto;
}

.panel-body::-webkit-scrollbar {
    width: 6px;
}

.panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.panel-body::-webkit-scrollbar-thumb {
    background: var(--color-neutral-300);
    border-radius: var(--radius-full);
}

body.dark-mode .panel-body::-webkit-scrollbar-thumb {
    background: var(--color-neutral-600);
}

/* ========== Tables ========== */
.sql-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.sql-table th {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}

.sql-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: top;
}

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

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

.sql-table tr.row-blocked td {
    background: rgba(239, 68, 68, 0.08);
}

.sql-table tr.row-warning td {
    background: rgba(245, 158, 11, 0.08);
}

body.dark-mode .sql-table tr.row-blocked td {
    background: rgba(239, 68, 68, 0.15);
}

body.dark-mode .sql-table tr.row-warning td {
    background: rgba(245, 158, 11, 0.15);
}

/* ========== Query Text ========== */
.query-text {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.query-text:hover {
    color: var(--primary-color);
    white-space: normal;
    word-break: break-all;
}

/* ========== Status Badges ========== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
}

.status-badge.status-running {
    background: var(--color-success-light);
    color: var(--color-success-dark);
}

.status-badge.status-sleeping {
    background: var(--color-neutral-100);
    color: var(--color-neutral-600);
}

.status-badge.status-suspended {
    background: var(--color-warning-light);
    color: var(--color-warning-dark);
}

.status-badge.status-blocked {
    background: var(--color-error-light);
    color: var(--color-error-dark);
}

body.dark-mode .status-badge.status-sleeping {
    background: var(--color-neutral-700);
    color: var(--color-neutral-300);
}

/* ========== Kill Button ========== */
.kill-btn {
    padding: 2px var(--space-2);
    border: 1px solid var(--color-error);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-error);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.kill-btn:hover {
    background: var(--color-error);
    color: white;
}

.kill-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========== Disk Space Bars ========== */
.space-bar-container {
    margin-bottom: var(--space-3);
}

.space-bar-container:last-child {
    margin-bottom: 0;
}

.space-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-1);
    font-size: var(--font-size-sm);
}

.space-bar-label .db-name {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.space-bar-label .db-size {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}

.space-bar-track {
    width: 100%;
    height: 20px;
    background: var(--color-neutral-100);
    border-radius: var(--radius-full);
    overflow: hidden;
    display: flex;
}

body.dark-mode .space-bar-track {
    background: var(--color-neutral-700);
}

.space-bar-fill-data {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary-400), var(--color-primary-600));
    transition: width var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    font-weight: var(--font-weight-semibold);
    min-width: 0;
}

.space-bar-fill-log {
    height: 100%;
    background: linear-gradient(90deg, var(--color-secondary-400), var(--color-secondary-600));
    transition: width var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    font-weight: var(--font-weight-semibold);
    min-width: 0;
}

.space-legend {
    display: flex;
    gap: var(--space-4);
    margin-top: var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.space-legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.space-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.space-legend-dot.data { background: var(--color-primary-500); }
.space-legend-dot.log { background: var(--color-secondary-500); }

/* ========== Wait Stats Bars ========== */
.wait-bar-container {
    margin-bottom: var(--space-3);
}

.wait-bar-container:last-child {
    margin-bottom: 0;
}

.wait-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-1);
}

.wait-bar-type {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

.wait-bar-value {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.wait-bar-track {
    width: 100%;
    height: 12px;
    background: var(--color-neutral-100);
    border-radius: var(--radius-full);
    overflow: hidden;
}

body.dark-mode .wait-bar-track {
    background: var(--color-neutral-700);
}

.wait-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-warning), var(--color-error));
    border-radius: var(--radius-full);
    transition: width var(--transition-base);
}

/* ========== Missing Index Cards ========== */
.index-card {
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    transition: all var(--transition-fast);
}

.index-card:last-child {
    margin-bottom: 0;
}

.index-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.index-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-3);
}

.index-card-table {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.index-card-score {
    font-size: var(--font-size-xs);
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-semibold);
    background: var(--color-warning-light);
    color: var(--color-warning-dark);
}

.index-card-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    font-size: var(--font-size-xs);
}

.index-detail-item {
    color: var(--text-secondary);
}

.index-detail-item strong {
    color: var(--text-primary);
}

.index-card-sql {
    background: var(--color-neutral-900);
    color: var(--color-success);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: var(--font-size-xs);
    overflow-x: auto;
    cursor: pointer;
    position: relative;
    transition: opacity var(--transition-fast);
    line-height: var(--line-height-relaxed);
    word-break: break-all;
    white-space: pre-wrap;
}

.index-card-sql:hover {
    opacity: 0.9;
}

.index-card-sql::after {
    content: '📋 Clique para copiar';
    position: absolute;
    top: var(--space-1);
    right: var(--space-2);
    font-size: 10px;
    color: var(--color-neutral-400);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.index-card-sql:hover::after {
    opacity: 1;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: var(--space-10);
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: var(--font-size-4xl);
    margin-bottom: var(--space-3);
}

.empty-state .empty-text {
    font-size: var(--font-size-sm);
}

/* ========== Skeleton Loading ========== */
.sql-skeleton {
    background: linear-gradient(90deg,
        var(--color-neutral-100) 25%,
        var(--color-neutral-200) 50%,
        var(--color-neutral-100) 75%
    );
    background-size: 200% 100%;
    animation: sql-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

body.dark-mode .sql-skeleton {
    background: linear-gradient(90deg,
        var(--color-neutral-700) 25%,
        var(--color-neutral-600) 50%,
        var(--color-neutral-700) 75%
    );
    background-size: 200% 100%;
}

@keyframes sql-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-row {
    height: 32px;
    margin-bottom: var(--space-2);
}

.skeleton-bar {
    height: 20px;
    margin-bottom: var(--space-3);
}

.skeleton-card-inner {
    height: 120px;
    margin-bottom: var(--space-3);
}

/* ========== Toast Notification ========== */
.sql-toast {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    background: var(--color-neutral-900);
    color: white;
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-tooltip);
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-base);
}

.sql-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.sql-toast.toast-success {
    background: var(--color-success-dark);
}

.sql-toast.toast-error {
    background: var(--color-error-dark);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sql-monitor-page {
        padding: var(--space-3);
    }

    .sql-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .server-info-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
}

/* ========== Tab Navigation ========== */
.tab-nav {
    display: flex;
    gap: var(--space-1);
    margin-bottom: var(--space-6);
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
    padding-bottom: 0;
}

.tab-btn {
    padding: var(--space-3) var(--space-4);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

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

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ========== Number Formatting ========== */
.num-highlight {
    font-weight: var(--font-weight-semibold);
    font-variant-numeric: tabular-nums;
}

.num-danger {
    color: var(--color-error);
}

.num-warning {
    color: var(--color-warning);
}

.num-success {
    color: var(--color-success);
}
