/* ============================================
   QAI Dashboard - Shared Theme Stylesheet
   Version: 1.0
   Description: Common styles for all dashboard pages
   ============================================ */

/* === DARK MODE VARIABLES === */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --accent-primary: #0f9d89;
    --accent-secondary: #0a7a6d;
    --border-color: #2d3561;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --info: #2196f3;
}

/* === GLOBAL RESETS === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* === CONTAINERS === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* === CARDS === */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.2);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-primary);
}

.card-title {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--accent-primary);
}

/* === BUTTONS === */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #555;
    color: white;
}

.btn-secondary:hover {
    background: #666;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #45a049;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #e68900;
}

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

.btn-danger:hover {
    background: #da190b;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: #0b7dda;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: var(--success);
    color: white;
}

.badge-warning {
    background: var(--warning);
    color: white;
}

.badge-error {
    background: var(--error);
    color: white;
}

.badge-info {
    background: var(--info);
    color: white;
}

.badge-secondary {
    background: #555;
    color: white;
}

/* === FORM ELEMENTS === */
.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95em;
    transition: border-color 0.3s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* === TABLES === */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

thead {
    background: var(--bg-secondary);
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

/* === METRICS === */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.metric-card {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--accent-primary);
}

.metric-label {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.metric-value {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--accent-primary);
}

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

/* === ALERTS === */
.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

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

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

.alert-info {
    background: rgba(33, 150, 243, 0.1);
    border-left: 4px solid var(--info);
    color: var(--info);
}

/* === LOADING SPINNER === */
.spinner {
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* === TOOLTIPS === */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    border: 1px solid var(--border-color);
    z-index: 1000;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* === MODALS === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.modal {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

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

.modal-title {
    font-size: 1.5em;
    color: var(--accent-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
}

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

/* === SCROLLBAR STYLING === */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

/* === UTILITY CLASSES === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }

.p-1 { padding: 10px; }
.p-2 { padding: 20px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { justify-content: center; align-items: center; }
.flex-between { justify-content: space-between; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }

.hidden { display: none !important; }
.visible { display: block !important; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 10px;
    }

    .card {
        padding: 15px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 0.9em;
    }
}
