/* ============================================
   Plechova huba — Modern Dashboard CSS
   ============================================ */

:root {
    --bg: #0f172a;
    --bg-raised: #1e293b;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --border-light: #475569;

    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-bg: rgba(99, 102, 241, 0.12);

    --accent: #f43f5e;
    --accent-bg: rgba(244, 63, 94, 0.12);

    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.12);

    --orange: #f59e0b;
    --orange-bg: rgba(245, 158, 11, 0.12);

    --purple: #a855f7;
    --purple-bg: rgba(168, 85, 247, 0.12);

    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.12);

    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;

    --sidebar-w: 240px;
    --transition: 0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-hover); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary); }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 36px; height: 36px;
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.brand-icon svg { width: 20px; height: 20px; color: var(--primary); }

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.brand-version { font-size: 0.7rem; color: var(--text-muted); }

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
    text-decoration: none;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-bg); color: var(--primary-hover); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.user-info svg { width: 16px; height: 16px; }

.logout-link { font-size: 0.8rem; color: var(--text-muted); }
.logout-link:hover { color: var(--accent); }

/* ---- Mobile ---- */
.mobile-header {
    display: none;
    position: fixed; top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
    z-index: 99;
}
.hamburger {
    background: none; border: none; color: var(--text); cursor: pointer;
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
}
.hamburger svg { width: 22px; height: 22px; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.5); }
    .mobile-header { display: flex; }
    .main { margin-left: 0; padding-top: 72px; }
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main {
    margin-left: var(--sidebar-w);
    padding: 2rem;
    min-height: 100vh;
}

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header .subtitle { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.15rem; }
.page-actions { display: flex; align-items: center; gap: 0.75rem; }

.breadcrumb { display: flex; align-items: center; gap: 0.4rem; color: var(--text-muted); font-size: 0.9rem; }
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb svg { color: var(--text-muted); }
.breadcrumb span { color: var(--text); font-weight: 600; }

/* ---- Flash messages ---- */
.flash-messages { margin-bottom: 1.5rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    animation: slideDown 0.3s ease;
}
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(16,185,129,0.2); }
.flash-warning { background: var(--orange-bg); color: var(--orange); border: 1px solid rgba(245,158,11,0.2); }
.flash-error { background: var(--accent-bg); color: var(--accent); border: 1px solid rgba(244,63,94,0.2); }

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

/* ============================================
   STATS CARDS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border-light); }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.orange { background: var(--orange-bg); color: var(--orange); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }

.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2 { font-size: 0.95rem; font-weight: 600; }

.card-body { padding: 1.25rem; }
.card-body.no-padding { padding: 0; }

/* ---- Grid ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ============================================
   TABLES
   ============================================ */
.table-responsive { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.7rem 1rem; text-align: left; }
th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
td {
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}
tr:hover td { background: rgba(99, 102, 241, 0.04); }
tr:last-child td { border-bottom: none; }

/* ---- Status badges ---- */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.status-completed, .status-badge.status-completed { background: var(--green-bg); color: var(--green); }
.status-active, .status-badge.status-active { background: var(--orange-bg); color: var(--orange); }
.status-failed, .status-badge.status-failed { background: var(--accent-bg); color: var(--accent); }

/* ============================================
   CHARTS & STATUS BARS
   ============================================ */
.chart-container { position: relative; height: 220px; }

.status-bars { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
.status-bar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.35rem; }
.status-count { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }

.progress-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}
.progress-completed { background: var(--green); }
.progress-active { background: var(--orange); }
.progress-failed { background: var(--accent); }

.quick-stats { display: flex; gap: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.quick-stat { display: flex; flex-direction: column; }
.qs-label { font-size: 0.75rem; color: var(--text-muted); }
.qs-value { font-size: 1.3rem; font-weight: 700; }
.qs-value.pulse { color: var(--orange); animation: pulse 2s infinite; }

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

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.input, select.input, textarea.input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color var(--transition);
    outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

textarea.input { resize: vertical; min-height: 80px; }

.input-table {
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
}
.input-table:focus { border-color: var(--primary); }

select.input, select.input-table {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    padding-right: 2rem;
}

.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

.form-actions { padding-top: 0.5rem; display: flex; gap: 0.75rem; }
.sticky-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 1rem 0;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }

.btn-outline { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); text-decoration: none; }

.btn-ghost { background: transparent; color: var(--primary-hover); padding: 0.3rem 0.6rem; }
.btn-ghost:hover { background: var(--primary-bg); text-decoration: none; }

.btn-danger { background: var(--accent-bg); color: var(--accent); border-color: rgba(244,63,94,0.2); }
.btn-danger:hover { background: rgba(244,63,94,0.2); text-decoration: none; }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-xs { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-full { width: 100%; }

/* ============================================
   CHAT MESSAGES
   ============================================ */
.chat { display: flex; flex-direction: column; gap: 0.75rem; }

.chat-msg { display: flex; }
.chat-user { justify-content: flex-end; }
.chat-assistant { justify-content: flex-start; }

.chat-bubble {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
}

.chat-user .chat-bubble {
    background: var(--primary-bg);
    border: 1px solid rgba(99,102,241,0.2);
    border-bottom-right-radius: 4px;
}
.chat-assistant .chat-bubble {
    background: var(--green-bg);
    border: 1px solid rgba(16,185,129,0.2);
    border-bottom-left-radius: 4px;
}

.chat-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.3rem;
    font-size: 0.7rem;
}
.chat-role { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.chat-user .chat-role { color: var(--primary-hover); }
.chat-assistant .chat-role { color: var(--green); }
.chat-time { color: var(--text-muted); }
.chat-text { font-size: 0.9rem; line-height: 1.5; }

/* ============================================
   LOG VIEWER
   ============================================ */
.log-viewer {
    max-height: 600px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    line-height: 1.7;
    padding: 0.75rem 0;
}
.log-line {
    padding: 0.15rem 1.25rem;
    white-space: pre-wrap;
    word-break: break-all;
}
.log-line:hover { background: var(--surface-hover); }
.log-error { color: var(--accent); }
.log-warn { color: var(--orange); }
.log-info { color: var(--text-secondary); }

/* ============================================
   INFO GRID
   ============================================ */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.info-item { display: flex; flex-direction: column; }
.info-item.full-width { grid-column: 1 / -1; }
.info-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 0.2rem; }
.info-value { font-size: 0.9rem; color: var(--text); }
.info-value.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--text-secondary); }

/* ============================================
   SEARCH
   ============================================ */
.search-form { display: flex; }
.search-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 0.7rem;
    transition: border-color var(--transition);
}
.search-input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.search-input-wrap svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.search-input {
    border: none;
    background: none;
    color: var(--text);
    padding: 0.5rem 0.6rem;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    width: 220px;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination { display: flex; justify-content: center; gap: 0.35rem; margin-top: 1.25rem; }
.page-link {
    display: flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px;
    padding: 0 0.6rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition);
}
.page-link:hover { border-color: var(--primary); color: var(--primary-hover); text-decoration: none; }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.dots { border: none; color: var(--text-muted); cursor: default; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.4; }
.empty-state p { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.25rem; }
.empty-state.small { padding: 2rem 1rem; }
.empty-state.small svg { width: 32px; height: 32px; }

/* ============================================
   MISC
   ============================================ */
.text-muted { color: var(--text-muted); font-size: 0.85rem; }
.mono { font-family: 'JetBrains Mono', monospace; }
strong { font-weight: 600; }

.toggle-label {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.8rem; color: var(--text-muted); cursor: pointer;
}
.toggle-label input { accent-color: var(--primary); }

.help-text { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.8; }
.help-text p { margin-bottom: 0.5rem; }

.action-buttons { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }

.action-result {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-top: 0.75rem;
    animation: slideDown 0.3s ease;
}
.action-result.success { background: var(--green-bg); color: var(--green); }
.action-result.error { background: var(--accent-bg); color: var(--accent); }

/* ---- Login page ---- */
.login-page { background: var(--bg); }
.login-wrap {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; padding: 1rem;
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-icon {
    width: 56px; height: 56px;
    background: var(--primary-bg);
    border-radius: var(--radius);
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 0.75rem;
}
.login-icon svg { width: 28px; height: 28px; color: var(--primary); }
.login-brand h1 { font-size: 1.4rem; font-weight: 700; }
.login-brand .text-muted { font-size: 0.85rem; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
