/* ============================================================
   MediaAssistant – Admin styles
   Sdílené styly pro všechny admin stránky (/admin/*)
   ============================================================ */

/* ── Access denied ── */
.adm-access-denied {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
    color: #57606a;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: #f6f8fa;
}

.adm-access-denied h2 {
    font-size: 22px;
    color: #1f2328;
    margin: 0 0 8px;
}

.adm-access-denied p {
    font-size: 14px;
    margin: 0 0 20px;
}

.adm-access-denied a {
    color: #0969da;
    text-decoration: none;
    font-size: 14px;
}

.adm-access-denied a:hover {
    text-decoration: underline;
}

/* ── Shell ── */
.adm-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #1f2328;
    background: #f6f8fa;
}

/* ── Sidebar ── */
.adm-sidebar {
    width: 210px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #d0d7de;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.adm-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #d0d7de;
    text-decoration: none;
    color: inherit;
}

.adm-logo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: #0969da;
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.adm-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.adm-logo-name {
    font-size: 13px;
    font-weight: 600;
}

.adm-logo-sub {
    font-size: 11px;
    color: #636c76;
}

.adm-nav {
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.adm-nav-spacer {
    flex: 1;
    min-height: 16px;
}

.adm-nav-link--back {
    color: #636c76;
    border-top: 1px solid #eaecef;
    margin-top: 4px;
    padding-top: 10px;
    border-radius: 0;
}

.adm-nav-link--back:hover {
    background: #fff5f5;
    color: #cf222e;
}

.adm-nav-section {
    font-size: 11px;
    font-weight: 600;
    color: #636c76;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 8px 4px;
}

.adm-nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: #1f2328;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.1s, color 0.1s;
}

.adm-nav-link:hover {
    background: #f6f8fa;
    color: #0969da;
}

.adm-nav-link.active {
    background: #dbeafe;
    color: #0969da;
    font-weight: 600;
}

.adm-nav-link svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* ── Content area ── */
.adm-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ── Header tools (fullscreen + close) ── */
.adm-page-tools {
    max-width: 1100px;
    padding: 0 28px;
    position: relative;
    height: 0;
    z-index: 10;
}

.adm-content:has(.adm-page--wide) .adm-page-tools {
    max-width: 1280px;
}

.adm-header-tools {
    position: absolute;
    top: 7px;
    right: 28px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.adm-tool-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #57606a;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.adm-tool-btn:hover {
    background: #f3f4f6;
    color: #1f2328;
}

.adm-tool-btn--close:hover {
    background: #fff0f0;
    color: #cf222e;
}

/* ── Page ── */
.adm-page {
    padding: 24px 28px;
    max-width: 1100px;
}

.adm-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    min-height: 48px;
}

.adm-page-header-info {
    align-self: flex-start;
}

.adm-page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.adm-page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.adm-page-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: #1f2328;
}

.adm-page-subtitle {
    font-size: 13px;
    color: #636c76;
    margin: 4px 0 0;
}

/* ── Alert / Status ── */
.adm-alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid;
}

.adm-alert--info    { background: #dbeafe; border-color: #93c5fd; color: #1e3a5f; }
.adm-alert--warning { background: #fef9c3; border-color: #fde047; color: #713f12; }
.adm-alert--error   { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.adm-alert--success { background: #dcfce7; border-color: #86efac; color: #14532d; }

/* ── Form card ── */
.adm-form-card {
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.adm-form-card h3 {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 600;
}

.adm-form-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 16px;
    align-items: center;
    margin-bottom: 16px;
}

.adm-form-grid label {
    font-size: 13px;
    font-weight: 500;
    color: #1f2328;
    text-align: right;
}

.adm-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Inputs ── */
.adm-input,
.adm-select,
.adm-textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: #1f2328;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.adm-input:focus,
.adm-select:focus,
.adm-textarea:focus {
    outline: none;
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
}

.adm-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.adm-input--sm { padding: 4px 8px; font-size: 12px; }

/* ── Buttons ── */
.adm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    background: #fff;
    color: #1f2328;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.adm-btn:hover:not(:disabled) { background: #f6f8fa; }
.adm-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.adm-btn--primary {
    background: #0969da;
    border-color: #0969da;
    color: #fff;
}
.adm-btn--primary:hover:not(:disabled) { background: #0860c8; border-color: #0860c8; }

.adm-btn--danger {
    background: #fff;
    border-color: #fca5a5;
    color: #cf222e;
}
.adm-btn--danger:hover:not(:disabled) { background: #fff0f0; }

.adm-btn--sm { padding: 4px 10px; font-size: 12px; }

/* ── Table ── */
.adm-table-wrap {
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: hidden;
}

.adm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.adm-table th {
    text-align: left;
    padding: 9px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #636c76;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: #f6f8fa;
    border-bottom: 1px solid #d0d7de;
}

.adm-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eaecef;
    vertical-align: middle;
}

.adm-table tr:last-child td { border-bottom: none; }

.adm-table tbody tr:hover { background: #f6f8fa; }

.adm-row--inactive td { opacity: 0.5; }
.adm-row--edit { background: #fffbeb !important; }

/* ── Table specific columns ── */
.adm-col-id    { width: 50px; color: #636c76; font-size: 12px; }
.adm-col-code  { width: 100px; }
.adm-col-date  { width: 110px; color: #636c76; font-size: 12px; }
.adm-col-act   { width: 60px; text-align: center; }
.adm-col-actions { width: 120px; text-align: right; }

.adm-code-chip {
    display: inline-block;
    padding: 2px 7px;
    background: #f0f4ff;
    color: #0969da;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

/* ── Toggle switch ── */
.adm-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.adm-toggle input { opacity: 0; width: 0; height: 0; }

.adm-toggle-slider {
    position: absolute;
    inset: 0;
    background: #d0d7de;
    border-radius: 20px;
    transition: background 0.2s;
}

.adm-toggle-slider::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.adm-toggle input:checked + .adm-toggle-slider { background: #0969da; }
.adm-toggle input:checked + .adm-toggle-slider::before { transform: translateX(16px); }

/* ── Tier badges ── */
.adm-tier { display: inline-flex; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.adm-tier--pro   { background: #fff3cd; color: #856404; }
.adm-tier--flash { background: #d1ecf1; color: #0c5460; }
.adm-tier--ultra { background: #f8d7da; color: #721c24; }
.adm-tier--lite  { background: #e2e3e5; color: #383d41; }

.adm-new-badge {
    display: inline-flex;
    padding: 1px 6px;
    background: #0969da;
    color: #fff;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 6px;
}

/* ── Version & status badges ── */
.adm-ver-badge {
    display: inline-flex;
    padding: 1px 7px;
    background: #dbeafe;
    color: #0969da;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    font-family: monospace;
}

.adm-draft-badge {
    display: inline-flex;
    padding: 1px 7px;
    background: #fff3cd;
    color: #856404;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.adm-live-badge {
    display: inline-flex;
    padding: 1px 7px;
    background: #dcfce7;
    color: #14532d;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.adm-archived-badge {
    display: inline-flex;
    padding: 1px 7px;
    background: #e2e3e5;
    color: #383d41;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

/* ── Prompt content editor ── */
.adm-prompt-editor {
    min-height: 260px;
    font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
}

/* ── Row action buttons ── */
.adm-row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Empty state ── */
.adm-empty {
    text-align: center;
    padding: 48px 20px;
    color: #636c76;
    font-size: 14px;
}

/* ── Inline edit row ── */
.adm-inline-form td { background: #fffbeb; padding: 8px 12px; }

/* ── Sync info bar ── */
.adm-sync-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    gap: 16px;
}

.adm-sync-bar-info { color: #636c76; }
.adm-sync-bar-info strong { color: #1f2328; }

/* ── Index landing ── */
.adm-index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

.adm-index-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 10px;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.adm-index-card:hover {
    border-color: #0969da;
    box-shadow: 0 2px 8px rgba(9,105,218,0.1);
}

.adm-index-card svg { color: #0969da; }

.adm-index-card-name {
    font-size: 15px;
    font-weight: 600;
}

.adm-index-card-desc {
    font-size: 12px;
    color: #636c76;
    line-height: 1.4;
}

/* ── User detail (expandable) ── */
.adm-row--selected {
    background: #f6f8fa !important;
}

.adm-detail-row {
    background: #f6f8fa;
}

.adm-detail-row td {
    padding: 0 !important;
}

.adm-user-detail {
    padding: 16px 20px;
    border-top: 1px solid #d0d7de;
}

.adm-user-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.adm-user-detail-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.adm-identity-count {
    display: inline-block;
    padding: 2px 8px;
    background: #ddf4ff;
    color: #0969da;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.adm-identity-form {
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}

.adm-identity-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    overflow: hidden;
}

.adm-identity-table thead {
    background: #f6f8fa;
    border-bottom: 1px solid #d0d7de;
}

.adm-identity-table th {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    color: #636c76;
}

.adm-identity-table td {
    padding: 10px 12px;
    border-top: 1px solid #d0d7de;
    font-size: 13px;
}

.adm-identity-table tbody tr:first-child td {
    border-top: none;
}

.adm-identity-table tbody tr:hover {
    background: #f6f8fa;
}

/* ── User info section ── */
.adm-user-info-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #d0d7de;
}

.adm-user-info-form {
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 12px;
    margin-top: 8px;
}

.adm-user-info-display {
    margin-top: 8px;
}

.adm-info-row {
    display: flex;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

.adm-info-label {
    width: 100px;
    color: #636c76;
    font-weight: 500;
}

.adm-info-value {
    flex: 1;
    color: #1f2328;
}

.adm-identities-section {
    /* identity table již má styly výše */
}

/* ── Expand indicator ── */
.adm-expand-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #636c76;
    transition: transform 0.2s;
}

.adm-expand-indicator svg {
    transition: transform 0.2s;
}

.adm-chevron--expanded {
    transform: rotate(180deg);
}

.adm-table tbody tr:hover .adm-expand-indicator {
    color: #0969da;
}

/* ================================================================
   API Logs Dashboard
   ================================================================ */

.adm-page--wide { max-width: 1280px; }

/* ── Stats grid ── */
.adm-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.adm-stat-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 10px;
    padding: 18px 20px;
}

.adm-stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    flex-shrink: 0;
}

.adm-stat-icon--blue  { background: #dbeafe; color: #2563eb; }
.adm-stat-icon--amber { background: #fef3c7; color: #d97706; }
.adm-stat-icon--green { background: #dcfce7; color: #16a34a; }
.adm-stat-icon--red   { background: #fee2e2; color: #dc2626; }

.adm-stat-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.adm-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #1f2328;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.adm-stat-label {
    font-size: 12px;
    color: #636c76;
    margin-top: 2px;
}

.adm-stat-sub {
    font-size: 11px;
    color: #8b949e;
    margin-top: 4px;
}

.adm-stat-sub strong { color: #1f2328; }
.adm-stat-sub--error { color: #dc2626 !important; }

/* ── Chart card ── */
.adm-chart-card {
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 20px;
}

.adm-chart-title {
    margin: 0 0 16px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2328;
}

.adm-chart {
    display: flex;
    align-items: stretch;
    gap: 8px;
    height: 140px;
    padding-bottom: 2px;
}

.adm-chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.adm-chart-bar-wrap {
    flex: 1;
    width: 100%;
    max-width: 48px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.adm-chart-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.3s ease;
    cursor: default;
}

.adm-chart-bar-stack {
    width: 100%;
    border-radius: 4px 4px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 2px;
    transition: height 0.3s ease;
    cursor: default;
}

.adm-bar-seg {
    min-height: 1px;
}

.adm-chart-count {
    font-size: 11px;
    font-weight: 600;
    color: #1f2328;
}

.adm-chart-label {
    font-size: 10px;
    color: #636c76;
}

.adm-chart-legend {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #eaecef;
    font-size: 11px;
    color: #636c76;
}

.adm-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.adm-chart-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Log filters ── */
.adm-log-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 16px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 10px;
}

.adm-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.adm-filter-label {
    font-size: 11px;
    font-weight: 600;
    color: #636c76;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.adm-btn-group {
    display: flex;
    gap: 0;
}

.adm-btn-group .adm-btn {
    border-radius: 0;
    margin-left: -1px;
}

.adm-btn-group .adm-btn:first-child {
    border-radius: 6px 0 0 6px;
    margin-left: 0;
}

.adm-btn-group .adm-btn:last-child {
    border-radius: 0 6px 6px 0;
}

.adm-select--filter {
    height: 30px;
    min-width: 120px;
    font-size: 12px;
    padding: 2px 8px;
    line-height: 1.4;
}

.adm-input--filter {
    height: 30px;
    min-width: 130px;
    font-size: 12px;
    padding: 2px 8px;
    line-height: 1.4;
}

.adm-input-clearable {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.adm-input-clearable .adm-input--filter {
    padding-right: 26px;
}

.adm-input-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #d0d7de;
    color: #656d76;
    cursor: pointer;
    transition: background 0.15s;
}

.adm-input-clear:hover {
    background: #afb8c1;
    color: #1f2328;
}

/* ── Log table specifics ── */
.adm-table--logs { font-size: 12px; }
.adm-table--logs td { padding: 7px 10px; }
.adm-table--logs th { padding: 7px 10px; text-align: left; }
.adm-table--logs th.adm-col-dur,
.adm-table--logs th.adm-col-type,
.adm-table--logs th.adm-col-tokens,
.adm-table--logs th.adm-col-cost,
.adm-table--logs th.adm-col-act { text-align: center; }

.adm-th-sort {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.adm-th-sort:hover {
    color: #0969da;
}

.adm-sort-icon {
    display: inline-block;
    width: 14px;
    font-size: 10px;
    color: #8b949e;
    vertical-align: middle;
    margin-left: 2px;
}

.adm-col-dur   { width: 80px; text-align: center; }
.adm-col-type  { width: 90px; text-align: center; }
.adm-col-user  { width: 80px; font-size: 11px; color: #636c76; }

.adm-dur-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 11px;
    font-weight: 600;
}

.adm-dur--fast   { background: #dcfce7; color: #15803d; }
.adm-dur--medium { background: #fef3c7; color: #b45309; }
.adm-dur--slow   { background: #fee2e2; color: #b91c1c; }

.adm-type-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: #f0f4ff;
    color: #4338ca;
}

.adm-type-badge--chat {
    background: #faf5ff;
    color: #7c3aed;
}

.adm-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.adm-status-dot--ok  { background: #22c55e; }
.adm-status-dot--err { background: #ef4444; }

.adm-row--error td { background: #fef2f2; }

.adm-log-model { font-size: 12px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-log-prompt { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-log-error { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dc2626; font-size: 11px; }

.adm-col-tokens { text-align: center; }
.adm-col-cost   { text-align: center; }
