/* ====== Fakturační systém - Stylesheet ====== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #f5f5f0;
    --surface: #ffffff;
    --surface-alt: #fafaf7;
    --border: #e5e5de;
    --border-light: #eeeeea;
    --text: #1a1a18;
    --text-muted: #6b6b65;
    --text-light: #9b9b95;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
    --font: 'DM Sans', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- Layout ---- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--text);
    color: #fff;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}
.sidebar-logo {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.sidebar-logo span {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.45);
    display: block;
    margin-top: 2px;
}

.sidebar-nav { padding: 12px 10px; flex: 1; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
    cursor: pointer;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.sidebar-nav a.active { color: #fff; background: var(--primary); }
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }

.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 28px 36px;
    max-width: 1200px;
}

/* ---- Header ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-top: 4px;
    font-family: var(--mono);
}
.stat-card.overdue .stat-value { color: var(--danger); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.87rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); border-color: #ccc; }
.btn svg { width: 16px; height: 16px; }

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

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-light);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

.btn-group { display: flex; gap: 8px; }

/* ---- Forms ---- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid .full-width { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-group textarea { resize: vertical; min-height: 70px; }

/* ---- Tables ---- */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
}
table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}
table tr:hover td { background: var(--surface-alt); }
table .mono { font-family: var(--mono); font-size: 0.85rem; }
table .text-right { text-align: right; }
table .actions { white-space: nowrap; }

/* ---- Status Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-draft { background: #f1f1ee; color: var(--text-muted); }
.badge-issued { background: var(--primary-light); color: var(--primary); }
.badge-paid { background: var(--success-light); color: var(--success); }
.badge-overdue { background: var(--danger-light); color: var(--danger); }
.badge-cancelled { background: #f1f1ee; color: var(--text-light); text-decoration: line-through; }

/* ---- Invoice Items Editor ---- */
.items-table { margin-top: 12px; }
.items-table th { font-size: 0.72rem; padding: 8px 6px; }
.items-table td { padding: 6px; border-bottom: 1px solid var(--border-light); }
.items-table input, .items-table select {
    padding: 7px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--font);
    font-size: 0.85rem;
    width: 100%;
    background: var(--surface);
}
.items-table .col-desc { min-width: 200px; }
.items-table .col-num { width: 90px; }
.items-table .col-unit { width: 70px; }
.items-table .col-vat { width: 80px; }
.items-table .col-total { width: 110px; text-align: right; font-family: var(--mono); font-weight: 600; }
.items-table .col-action { width: 40px; text-align: center; }

.items-summary {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}
.items-summary table { width: 300px; }
.items-summary td { padding: 6px 14px; font-size: 0.9rem; }
.items-summary .total-row td {
    font-weight: 700;
    font-size: 1.05rem;
    border-top: 2px solid var(--text);
    padding-top: 10px;
}

/* ---- Search Bar ---- */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.search-bar input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
}
.search-bar input:focus { outline: none; border-color: var(--primary); }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.15rem; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* ---- Invoice Print View ---- */
.invoice-preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px;
    box-shadow: var(--shadow);
    max-width: 800px;
}
.invoice-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--text);
}
.invoice-title {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.04em;
}
.invoice-number {
    font-family: var(--mono);
    font-size: 1.1rem;
    color: var(--text-muted);
}
.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 28px;
}
.invoice-party h4 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.invoice-party .party-name {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.invoice-party .party-detail {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.7;
}
.invoice-dates {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 16px 0;
    margin-bottom: 20px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.invoice-dates .date-item label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    display: block;
}
.invoice-dates .date-item span {
    font-family: var(--mono);
    font-size: 0.9rem;
    font-weight: 500;
}
.invoice-items-table { margin-bottom: 20px; }
.invoice-items-table th {
    background: var(--surface-alt);
    padding: 8px 12px;
    font-size: 0.72rem;
}
.invoice-items-table td { padding: 10px 12px; font-size: 0.87rem; }
.invoice-items-table .mono { font-family: var(--mono); }

.invoice-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 40px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.invoice-qr { text-align: center; }
.invoice-qr canvas, .invoice-qr img { margin-bottom: 6px; }
.invoice-qr .qr-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.invoice-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 16px;
}

/* ---- Tabs ---- */
.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}
.tab-bar button {
    padding: 8px 16px;
    border: none;
    background: none;
    font-family: var(--font);
    font-size: 0.87rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.tab-bar button:hover { color: var(--text); }
.tab-bar button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    background: var(--text);
    color: #fff;
    font-size: 0.87rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

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

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 0.95rem; }

/* ---- Print ---- */
@media print {
    .sidebar, .page-header, .no-print, .btn-group { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; max-width: 100% !important; }
    .invoice-preview { border: none; box-shadow: none; padding: 15px; font-size: 13px; }
    .invoice-header-row { margin-bottom: 16px; padding-bottom: 12px; }
    .invoice-title { font-size: 1.4rem; }
    .invoice-number { font-size: 0.95rem; }
    .invoice-parties { grid-template-columns: 1fr 1fr !important; gap: 24px; margin-bottom: 16px; }
    .invoice-party h4 { margin-bottom: 4px; }
    .invoice-party .party-name { font-size: 0.95rem; }
    .invoice-party .party-detail { font-size: 0.8rem; line-height: 1.5; }
    .invoice-dates { grid-template-columns: repeat(4, 1fr) !important; gap: 10px; padding: 10px 0; margin-bottom: 12px; }
    .invoice-dates .date-item label { font-size: 0.65rem; }
    .invoice-dates .date-item span { font-size: 0.82rem; }
    .invoice-items-table th { padding: 5px 8px; font-size: 0.68rem; }
    .invoice-items-table td { padding: 6px 8px; font-size: 0.8rem; }
    .items-summary td { padding: 4px 10px; font-size: 0.82rem; }
    .items-summary .total-row td { font-size: 0.95rem; padding-top: 6px; }
    .invoice-footer { margin-top: 16px; padding-top: 12px; gap: 24px; }
    .invoice-qr svg { width: 100px !important; height: 100px !important; }
    .invoice-note { font-size: 0.78rem; }
    .badge { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    body { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-logo h1, .sidebar-logo span, .sidebar-nav a span { display: none; }
    .sidebar-nav a { justify-content: center; padding: 12px; }
    .main-content { margin-left: 60px; padding: 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .invoice-parties { grid-template-columns: 1fr; gap: 20px; }
    .invoice-dates { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .invoice-preview { padding: 24px; }
}

/* ---- Remove btn (inline) ---- */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s;
}
.btn-icon:hover { color: var(--danger); background: var(--danger-light); }

/* ---- Loading ---- */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ---- ARES Autocomplete ---- */
.ares-wrapper { position: relative; }
.ares-input-row {
    display: flex;
    gap: 8px;
}
.ares-input-row input { flex: 1; }
.ares-input-row .btn { flex-shrink: 0; align-self: flex-end; }
.ares-dropdown {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    max-height: 260px;
    overflow-y: auto;
}
.ares-dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}
.ares-dropdown-item:last-child { border-bottom: none; }
.ares-dropdown-item:hover { background: var(--primary-light); }
.ares-dropdown-item .ares-name {
    font-weight: 600;
    font-size: 0.9rem;
}
.ares-dropdown-item .ares-detail {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.ares-hint {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 4px;
}
.ares-spinner {
    padding: 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}
