/* === Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --purple: #522583;
    --purple-light: #6B35A8;
    --purple-dark: #3D1B63;
    --bg: #F8F6FB;
    --bg-card: #FFFFFF;
    --text: #1a1a2e;
    --text-secondary: #555;
    --border: #E8DCF4;
    --gradient: linear-gradient(135deg, #F3EDF8 0%, #E8DCF4 100%);
    --shadow: 0 2px 12px rgba(82, 37, 131, 0.08);
    --shadow-lg: 0 8px 32px rgba(82, 37, 131, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

html { font-size: 15px; }

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* === Navbar === */
.navbar {
    background: var(--purple);
    color: white;
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo {
    border-radius: 6px;
    object-fit: contain;
}

.nav-title {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.nav-logout { opacity: 0.7; }
.nav-logout:hover { opacity: 1; }

.nav-user {
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    padding-left: 0.5rem;
    border-left: 1px solid rgba(255,255,255,0.2);
}

/* === Container === */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--purple);
}

.header-stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.stat-pill {
    background: var(--gradient);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-value {
    font-weight: 800;
    color: var(--purple);
    font-size: 0.95rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* === Sections === */
.section {
    margin-bottom: 2.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--purple);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

/* === Card === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border: 1px solid var(--border);
}

/* === Org Chart Tree === */
.org-scroll {
    overflow-x: auto;
    padding: 20px 0 30px;
}

.otree, .otree ul {
    display: flex;
    justify-content: center;
    list-style: none;
    margin: 0;
    padding: 28px 4px 0;
    position: relative;
}

.otree { padding-top: 0; }

.otree li {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 28px 4px 0;
}

/* Vertical line DOWN from parent card to horizontal bar */
.otree li::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 28px;
    background: #cbb8e0;
    margin-left: -1px;
}

/* Horizontal bar connecting siblings */
.otree li::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #cbb8e0;
}

/* First child: bar only right half */
.otree li:first-child::after { left: 50%; }

/* Last child: bar only left half */
.otree li:last-child::after { right: 50%; }

/* Only child: no horizontal bar */
.otree li:only-child::after { display: none; }

/* Root node: no connectors above */
.otree > li::before,
.otree > li::after { display: none; }
.otree > li { padding-top: 0; }

/* Vertical line DOWN from card to children (via ul::before) */
.otree ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 28px;
    background: #cbb8e0;
    margin-left: -1px;
}

/* === Node Card === */
.ocard {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: white;
    min-width: 120px;
    max-width: 160px;
    padding: 8px 12px;
    border-radius: 10px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.15);
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.ocard:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
    z-index: 2;
}

.ocard strong {
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 2px;
}

.ocard span {
    font-size: 0.68rem;
    opacity: 0.85;
    line-height: 1.2;
}

/* Department colors */
.ocard--vedeni   { background: #522583; }
.ocard--vyroba   { background: #E67E22; }
.ocard--sklad    { background: #27AE60; }
.ocard--admin    { background: #2980B9; }
.ocard--obchod   { background: #C0392B; }
.ocard--marketing { background: #8E44AD; }

/* === Department Legend === */
.dept-legend {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.dept-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dept-color);
    background: color-mix(in srgb, var(--dept-color) 10%, white);
    border: 1px solid color-mix(in srgb, var(--dept-color) 25%, white);
}

.dept-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* === Data Table === */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    font-size: 0.9rem;
}

.data-table th {
    background: var(--gradient);
    color: var(--purple);
    font-weight: 700;
    padding: 12px 16px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #f0ecf5;
}

.data-table th.num, .data-table td.num {
    text-align: right;
}

.employee-row {
    cursor: pointer;
    transition: background 0.15s;
}

.employee-row:hover {
    background: #F8F4FC;
}

.name-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    white-space: nowrap;
}

.total-row td {
    background: var(--gradient);
    border-top: 2px solid var(--border);
    font-weight: 700;
    color: var(--purple);
}

/* === Bar Chart === */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-row {
    display: grid;
    grid-template-columns: 160px 1fr 110px;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
}

.bar-label {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-track {
    height: 28px;
    background: #f0ecf5;
    border-radius: 14px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 14px;
    transition: width 0.6s ease;
    min-width: 4px;
}

.bar-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--purple);
    text-align: right;
    white-space: nowrap;
}

/* === Employee Detail === */
.back-link {
    display: inline-block;
    color: var(--purple);
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding: 6px 0;
}

.back-link:hover { text-decoration: underline; }

.employee-header {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    border-top: 4px solid var(--dept-color);
}

.employee-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.employee-info { flex: 1; min-width: 200px; }

.employee-name {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 2px;
}

.employee-role {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 8px;
}

.employee-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.meta-item {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.employee-cost-summary {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.cost-item {
    text-align: center;
}

.cost-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--purple);
}

.cost-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Salary Grid === */
.salary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.salary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
}

.salary-card.highlight {
    background: var(--gradient);
    border-color: var(--purple);
}

.salary-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.salary-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--purple);
}

/* === Activities === */
.activities-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    transition: box-shadow 0.2s;
}

.activity-card:hover {
    box-shadow: var(--shadow);
}

.activity-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.activity-content { flex: 1; }

.activity-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.activity-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* === Auth Pages === */
.auth-body {
    background: var(--gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    text-align: center;
}

.auth-card-wide {
    max-width: 480px;
}

.auth-logo { margin-bottom: 1.5rem; }

.auth-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--purple);
    margin-bottom: 4px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.auth-form { text-align: left; }

/* === Forms === */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 4px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(82, 37, 131, 0.1);
}

.code-input {
    text-align: center;
    font-size: 1.8rem !important;
    letter-spacing: 8px;
    font-weight: 700;
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-row .form-group { flex: 1; min-width: 180px; }
.form-group-btn { flex: 0 !important; min-width: auto !important; }

.form-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--purple);
    color: white;
}

.btn-primary:hover {
    background: var(--purple-light);
}

.btn-secondary {
    background: #f0ecf5;
    color: var(--purple);
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
    background: #fef2f2;
    color: #c0392b;
}

.btn-danger:hover { background: #fde8e8; }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.alert-error {
    background: #fef2f2;
    color: #c0392b;
    border: 1px solid #fde8e8;
}

.alert-info {
    background: #F3EDF8;
    color: var(--purple);
    border: 1px solid var(--border);
}

/* === QR Code === */
.qr-container {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
}

.qr-image {
    width: 200px;
    height: 200px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
}

.secret-display {
    margin-bottom: 1.5rem;
    text-align: center;
}

.secret-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.secret-code {
    display: inline-block;
    background: #f0ecf5;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--purple);
    user-select: all;
}

/* === Admin === */
.admin-form {
    padding: 0.5rem 0;
}

.role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.role-admin { background: #F3EDF8; color: var(--purple); }
.role-viewer { background: #f0f9ff; color: #2980B9; }

.status-ok { color: #27AE60; font-weight: 700; font-size: 0.85rem; }
.status-pending { color: #E67E22; font-weight: 600; font-size: 0.85rem; }

.actions-cell {
    display: flex;
    gap: 6px;
    align-items: center;
}

.text-muted { color: #ccc; }

/* === Footer === */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* === Responsive === */
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; }
    .nav-title { display: none; }
    .container { padding: 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .header-stats { width: 100%; }
    .stat-pill { flex: 1; justify-content: center; }
    .employee-header { flex-direction: column; text-align: center; }
    .employee-meta { justify-content: center; }
    .employee-cost-summary { justify-content: center; }
    .salary-grid { grid-template-columns: 1fr 1fr; }
    .bar-row { grid-template-columns: 100px 1fr 90px; }
    .bar-label { font-size: 0.75rem; }
    .form-row { flex-direction: column; }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 8px 10px; }
}
