/* Czech Invoicing – frontend styles. Scoped to .ci-app. */

.ci-app { --ci-bg: #f7f8fa; --ci-card: #fff; --ci-border: #e3e5ea; --ci-text: #1b1f27;
    --ci-muted: #6b7280; --ci-primary: #2b6cb0; --ci-primary-dark: #1e4e82;
    --ci-danger: #c53030; --ci-success: #2f855a; --ci-warning: #b7791f;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--ci-text); background: var(--ci-bg); min-height: 80vh;
    padding: 0; margin: 0 -1em; /* bleed a bit if theme has padding */
}
.ci-app * { box-sizing: border-box; }

.ci-topbar { display: flex; align-items: center; gap: 24px; padding: 14px 24px;
    background: #fff; border-bottom: 1px solid var(--ci-border); }
.ci-brand { font-weight: 700; font-size: 16px; }
.ci-nav { display: flex; gap: 18px; flex: 1; }
.ci-nav a { color: var(--ci-text); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 14px; }
.ci-nav a:hover, .ci-nav a.is-active { background: #eef2f7; color: var(--ci-primary-dark); }
.ci-user { font-size: 13px; color: var(--ci-muted); }
.ci-user a { color: var(--ci-primary); }

.ci-view { padding: 24px; max-width: 1200px; margin: 0 auto; }
.ci-loading { padding: 40px; text-align: center; color: var(--ci-muted); }

/* Page header */
.ci-page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.ci-page-head h1 { margin: 0; font-size: 22px; }
.ci-page-head .ci-actions { display: flex; gap: 8px; }

/* Cards */
.ci-card { background: var(--ci-card); border: 1px solid var(--ci-border); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.ci-card h2 { margin-top: 0; font-size: 16px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ci-muted); }

/* Forms */
.ci-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 20px; }
.ci-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.ci-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.ci-field { display: flex; flex-direction: column; gap: 4px; }
.ci-field.full { grid-column: 1 / -1; }
.ci-field label { font-size: 12px; color: var(--ci-muted); font-weight: 500; }
.ci-field input[type=text], .ci-field input[type=email], .ci-field input[type=tel],
.ci-field input[type=number], .ci-field input[type=date], .ci-field select, .ci-field textarea {
    font: inherit; color: inherit; padding: 8px 10px; border: 1px solid var(--ci-border);
    border-radius: 6px; background: #fff; width: 100%;
}
.ci-field input:focus, .ci-field select:focus, .ci-field textarea:focus {
    outline: 2px solid var(--ci-primary); outline-offset: -1px; border-color: var(--ci-primary);
}
.ci-field textarea { min-height: 80px; resize: vertical; }
.ci-field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.ci-field.checkbox label { order: 2; font-size: 13px; color: var(--ci-text); }
.ci-help { font-size: 11px; color: var(--ci-muted); margin-top: 2px; }

/* Buttons */
.ci-btn { font: inherit; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--ci-border);
    background: #fff; color: var(--ci-text); cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; gap: 6px; }
.ci-btn:hover { background: #f1f3f6; }
.ci-btn.primary { background: var(--ci-primary); color: #fff; border-color: var(--ci-primary); }
.ci-btn.primary:hover { background: var(--ci-primary-dark); border-color: var(--ci-primary-dark); }
.ci-btn.danger { color: var(--ci-danger); border-color: var(--ci-danger); background: #fff; }
.ci-btn.danger:hover { background: var(--ci-danger); color: #fff; }
.ci-btn.ghost { background: transparent; border-color: transparent; color: var(--ci-primary); }
.ci-btn.ghost:hover { background: #eef2f7; }
.ci-btn[disabled] { opacity: .5; cursor: not-allowed; }
.ci-btn.sm { padding: 4px 8px; font-size: 12px; }

/* Tables */
.ci-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--ci-border); border-radius: 8px; overflow: hidden; }
.ci-table th, .ci-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--ci-border); font-size: 14px; }
.ci-table th { background: #f6f7f9; font-weight: 600; font-size: 12px; text-transform: uppercase; color: var(--ci-muted); letter-spacing: 0.5px; }
.ci-table tr:last-child td { border-bottom: none; }
.ci-table tr:hover td { background: #fafbfc; }
.ci-table .r { text-align: right; }
.ci-table .c { text-align: center; }
.ci-table a { color: var(--ci-primary); text-decoration: none; }
.ci-table a:hover { text-decoration: underline; }

/* Status badges */
.ci-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.ci-badge.draft { background: #fff3cd; color: #856404; }
.ci-badge.issued { background: #d4edda; color: #155724; }
.ci-badge.cancelled { background: #f8d7da; color: #721c24; }

/* Invoice form - line items */
.ci-items { width: 100%; border-collapse: collapse; }
.ci-items th { background: #f6f7f9; padding: 8px; font-size: 11px; text-transform: uppercase; color: var(--ci-muted); text-align: left; border-bottom: 1px solid var(--ci-border); }
.ci-items td { padding: 6px 4px; border-bottom: 1px solid #f0f1f3; vertical-align: top; }
.ci-items .col-desc { width: 40%; }
.ci-items .col-qty, .ci-items .col-unit { width: 10%; }
.ci-items .col-price, .ci-items .col-vat { width: 12%; }
.ci-items .col-total { width: 14%; }
.ci-items .col-action { width: 2%; }
.ci-items input, .ci-items select, .ci-items textarea {
    width: 100%; padding: 6px 8px; border: 1px solid transparent; background: transparent;
    font: inherit; color: inherit; border-radius: 4px;
}
.ci-items input:focus, .ci-items select:focus, .ci-items textarea:focus {
    border-color: var(--ci-primary); background: #fff; outline: none;
}
.ci-items input.r, .ci-items .r { text-align: right; }
.ci-items .line-total { padding: 6px 8px; text-align: right; font-weight: 500; }
.ci-items .remove-row { background: none; border: none; color: var(--ci-muted); cursor: pointer; font-size: 16px; padding: 4px; }
.ci-items .remove-row:hover { color: var(--ci-danger); }

/* Totals block */
.ci-totals { margin-top: 20px; display: flex; justify-content: flex-end; }
.ci-totals table { border-collapse: collapse; min-width: 340px; }
.ci-totals td { padding: 4px 12px; font-size: 14px; }
.ci-totals tr.grand td { border-top: 2px solid var(--ci-text); padding-top: 10px; font-size: 18px; font-weight: 700; }
.ci-totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* Toast */
.ci-toast { position: fixed; top: 20px; right: 20px; padding: 12px 18px; border-radius: 8px; background: #333; color: #fff; z-index: 9999; box-shadow: 0 4px 20px rgba(0,0,0,0.15); max-width: 400px; }
.ci-toast.success { background: var(--ci-success); }
.ci-toast.error { background: var(--ci-danger); }
.ci-toast.warning { background: var(--ci-warning); }

/* Duplicate warning */
.ci-warning-block { background: #fff3cd; border-left: 4px solid var(--ci-warning); padding: 10px 14px; margin: 10px 0; font-size: 13px; color: #856404; border-radius: 4px; }

/* Info banner */
.ci-info { background: #e0f2fe; border-left: 4px solid #2b6cb0; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; border-radius: 4px; }

/* Empty state */
.ci-empty { text-align: center; padding: 60px 20px; color: var(--ci-muted); }
.ci-empty h3 { margin: 0 0 8px 0; color: var(--ci-text); }

/* Row actions on list */
.ci-row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Filter bar */
.ci-filters { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; padding: 12px; background: #fff; border: 1px solid var(--ci-border); border-radius: 8px; }
.ci-filters label { font-size: 12px; color: var(--ci-muted); }
.ci-filters select, .ci-filters input { padding: 6px 8px; border: 1px solid var(--ci-border); border-radius: 4px; font: inherit; }

/* Responsive */
@media (max-width: 760px) {
    .ci-grid, .ci-grid.cols-3, .ci-grid.cols-4 { grid-template-columns: 1fr; }
    .ci-topbar { flex-wrap: wrap; }
    .ci-nav { order: 3; width: 100%; overflow-x: auto; }
    .ci-items { display: block; }
    .ci-items thead { display: none; }
    .ci-items tbody, .ci-items tr, .ci-items td { display: block; width: 100%; }
    .ci-items tr { border: 1px solid var(--ci-border); border-radius: 8px; margin-bottom: 10px; padding: 8px; }
    .ci-items td { border: none; padding: 4px 0; }
    .ci-items td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--ci-muted); text-transform: uppercase; }
}

/* Logo preview */
.ci-logo-preview { max-height: 80px; max-width: 200px; border: 1px solid var(--ci-border); padding: 6px; border-radius: 6px; background: #fff; }

/* Utility */
.ci-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ci-muted { color: var(--ci-muted); }
.ci-right { text-align: right; }
.ci-tight { margin: 0; padding: 0; }
hr.ci-sep { border: none; border-top: 1px solid var(--ci-border); margin: 20px 0; }
