/* =============================================================================
   AI Asistent Davida – Dashboard Styles
   ============================================================================= */

:root {
    /* Light Mode Colors (Liquid Glass) */
    --bg-primary: #f2f2f7;
    --bg-secondary: rgba(255, 255, 255, 0.75);
    --bg-card: rgba(255, 255, 255, 0.65);
    --bg-card-hover: rgba(255, 255, 255, 0.9);
    --border: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(99, 102, 241, 0.3);

    --text-primary: #1c1c1e;
    --text-secondary: #3a3a3c;
    --text-muted: #8e8e93;

    --accent: #007aff;
    --accent-light: #5ac8fa;
    --accent-glow: rgba(0, 122, 255, 0.15);

    --green: #34c759;
    --green-bg: rgba(52, 199, 89, 0.15);
    --yellow: #ffcc00;
    --yellow-bg: rgba(255, 204, 0, 0.15);
    --red: #ff3b30;
    --red-bg: rgba(255, 59, 48, 0.15);
    --blue: #007aff;

    /* Spacing */
    --gap: 20px;
    --radius: 14px;
    --radius-sm: 8px;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* ===== Header ===== */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 32px;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: var(--green-bg);
    border: 1px solid rgba(34, 197, 94, 0.2);
    transition: all 0.3s ease;
}

.status-badge.degraded {
    background: var(--yellow-bg);
    border-color: rgba(234, 179, 8, 0.2);
}

.status-badge.offline {
    background: var(--red-bg);
    border-color: rgba(239, 68, 68, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s infinite;
}

.status-badge.degraded .status-dot { background: var(--yellow); }
.status-badge.offline .status-dot { background: var(--red); animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.uptime {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ===== Dashboard Layout ===== */

.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--gap) 32px;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

/* ===== Metrics Row ===== */

.metrics-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap);
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.metric-card:hover {
    border-color: var(--border-glow);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.metric-card:hover::before { opacity: 1; }

.metric-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.metric-icon { font-size: 18px; }

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

.metric-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.metric-sub {
    font-size: 13px;
    color: var(--text-muted);
}

/* Progress Bar */
.progress-bar {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    margin-top: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--green), var(--accent));
    transition: width 0.6s ease, background 0.3s ease;
    width: 0%;
}

.progress-fill.warning {
    background: linear-gradient(90deg, var(--yellow), #f59e0b);
}

.progress-fill.danger {
    background: linear-gradient(90deg, var(--red), #dc2626);
}

/* ===== Content Rows ===== */

.content-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap);
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.panel-wide { grid-column: 1; }
.panel-full { grid-column: 1 / -1; }

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

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.refresh-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.refresh-btn:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent-light);
    transform: rotate(90deg);
}

/* ===== Channel List ===== */

.channel-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.channel {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.channel:hover {
    border-color: var(--border);
    background: var(--bg-secondary);
}

.channel-icon { font-size: 24px; }

.channel-info { flex: 1; }

.channel-name {
    font-size: 14px;
    font-weight: 500;
}

.channel-detail {
    font-size: 12px;
    color: var(--text-muted);
}

.channel-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 12px;
}

.channel-status.online {
    background: var(--green-bg);
    color: var(--green);
}

.channel-status.offline {
    background: var(--red-bg);
    color: var(--red);
}

.channel-status.paused {
    background: var(--yellow-bg);
    color: var(--yellow);
}

/* ===== Component Grid ===== */

.component-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.component {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.component-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.component-dot.ok { background: var(--green); }
.component-dot.err { background: var(--red); }
.component-dot.warn { background: var(--yellow); }

/* ===== Task List ===== */

.task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.task-item:hover {
    border-color: var(--border);
}

.task-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.task-badge.completed { background: var(--green-bg); color: var(--green); }
.task-badge.failed { background: var(--red-bg); color: var(--red); }
.task-badge.deferred { background: var(--yellow-bg); color: var(--yellow); }
.task-badge.executing { background: rgba(59, 130, 246, 0.1); color: var(--blue); }
.task-badge.waiting { background: var(--accent-glow); color: var(--accent-light); }

.task-desc {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-time {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Action Buttons ===== */

.action-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.action-btn:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    transform: translateX(4px);
}

/* ===== Task Dialog ===== */

.task-dialog {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.task-dialog textarea {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    resize: vertical;
    transition: border-color 0.2s;
}

.task-dialog textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.dialog-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-primary {
    padding: 8px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
}

.btn-secondary {
    padding: 8px 20px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-small {
    padding: 4px 10px;
    font-size: 11px;
    margin-left: auto;
}

/* ===== Budget Details ===== */

.budget-details {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.budget-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

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

.budget-value {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.budget-value.accent {
    color: var(--accent-light);
}

/* ===== Footer ===== */

.footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    margin-top: 20px;
}

/* ===== Responsive ===== */

@media (max-width: 1024px) {
    .metrics-row { grid-template-columns: repeat(2, 1fr); }
    .content-row { grid-template-columns: 1fr; }
    .budget-details { grid-template-columns: repeat(3, 1fr); }
    .dashboard { padding: var(--gap) 16px; }
    .header { padding: 12px 16px; }
}

@media (max-width: 640px) {
    .metrics-row { grid-template-columns: 1fr; }
    .budget-details { grid-template-columns: repeat(2, 1fr); }
    .component-grid { grid-template-columns: 1fr; }
}

/* ===== Scrollbar ===== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Animations ===== */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.metric-card, .panel {
    animation: fadeIn 0.4s ease forwards;
}

.metric-card:nth-child(2) { animation-delay: 0.05s; }
.metric-card:nth-child(3) { animation-delay: 0.1s; }
.metric-card:nth-child(4) { animation-delay: 0.15s; }
