/* Nadlan Pro — base styles (RTL) */

:root {
    --bg-page: #f5f7fa;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-muted: #f7fafc;
    --text-primary: #1a202c;
    --text-muted: #718096;
    --text-heading: #2d3748;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.05);
}

[data-theme="dark"] {
    --bg-page: #1a202c;
    --bg-card: #2d3748;
    --bg-input: #4a5568;
    --bg-muted: #4a5568;
    --text-primary: #f7fafc;
    --text-muted: #a0aec0;
    --text-heading: #f7fafc;
    --border-color: #4a5568;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-theme="dark"] .card {
    background: var(--bg-card) !important;
    color: var(--text-primary);
}
[data-theme="dark"] .topbar {
    background: var(--bg-card);
    border-color: var(--border-color);
}
[data-theme="dark"] .main-nav a { color: var(--text-primary); }
[data-theme="dark"] .main-nav a:hover { background: var(--bg-muted); }
[data-theme="dark"] .stat { background: var(--bg-muted); }
[data-theme="dark"] .form-stack input,
[data-theme="dark"] .form-stack textarea,
[data-theme="dark"] .form-stack select {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] .info-card { background: var(--bg-muted); }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", "Heebo", Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.2s, color 0.2s;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Topbar */
.topbar {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
    color: #2d3748;
}

.main-nav {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.main-nav a {
    color: #4a5568;
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.15s;
}

.main-nav a:hover { background: #edf2f7; }
.main-nav a.active { background: #ebf8ff; color: #2b6cb0; }

.badge {
    background: #fef5e7;
    color: #b7791f;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Main */
main { padding: 2rem 0; }

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header { margin-bottom: 1rem; }
.card h1 { margin-top: 0; font-size: 1.75rem; }
.card h2 { margin-top: 0; font-size: 1.25rem; }

.muted { color: #718096; }
.small { font-size: 0.85rem; }

/* Stats (home) */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat {
    background: #f7fafc;
    padding: 1.25rem;
    border-radius: 8px;
    text-align: center;
}

.stat-value { font-size: 2rem; font-weight: 700; color: #2b6cb0; }
.stat-label { color: #718096; font-size: 0.9rem; margin-top: 0.25rem; }

a { color: #2b6cb0; }
a:hover { color: #2c5282; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-primary {
    background: #2b6cb0;
    color: white;
    border-color: #2b6cb0;
}
.btn-primary:hover { background: #2c5282; color: white; }

.btn-secondary {
    background: #edf2f7;
    color: #2d3748;
    border-color: #cbd5e0;
}
.btn-secondary:hover { background: #e2e8f0; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
    background: white;
    color: #c53030;
    border-color: #fc8181;
}
.btn-danger:hover { background: #fff5f5; }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

/* Add-form (details/summary expand) */
.add-form {
    margin-bottom: 1rem;
}
.add-form summary {
    list-style: none;
    cursor: pointer;
    display: inline-block;
}
.add-form summary::-webkit-details-marker { display: none; }
.add-form[open] summary { margin-bottom: 1rem; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 8px;
}
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.form-grid label span {
    font-size: 0.85rem;
    color: #4a5568;
    font-weight: 500;
}
.form-grid label em {
    color: #c53030;
    font-style: normal;
}
.form-grid input, .form-grid textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    background: white;
}
.form-grid input:focus, .form-grid textarea:focus {
    outline: 2px solid #4299e1;
    outline-offset: -1px;
    border-color: transparent;
}
.form-grid .full-row { grid-column: 1 / -1; }
.form-grid button { justify-self: start; }

/* Profiles table */
.profiles-table {
    width: 100%;
    border-collapse: collapse;
}
.profiles-table th {
    text-align: right;
    padding: 0.75rem;
    border-bottom: 2px solid #e2e8f0;
    color: #4a5568;
    font-weight: 600;
    font-size: 0.9rem;
}
.profiles-table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid #edf2f7;
    vertical-align: top;
}
.profiles-table tr:hover { background: #f7fafc; }

.row-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Status badges */
.status {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-new { background: #fef5e7; color: #b7791f; }
.status-connecting { background: #bee3f8; color: #2a4365; animation: pulse 1.5s ease-in-out infinite; }
.status-active { background: #c6f6d5; color: #22543d; }
.status-expired { background: #fed7d7; color: #9b2c2c; }
.status-blocked { background: #feb2b2; color: #742a2a; }
.status-disabled { background: #e2e8f0; color: #4a5568; }

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

.counter { color: #a0aec0; font-weight: 400; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #718096;
}

/* Info card */
.info-card { background: #ebf8ff; border: 1px solid #bee3f8; }
.info-card h2 { color: #2c5282; }
.info-card ol { margin: 0.5rem 0 0; padding-right: 1.5rem; }

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}
.flash-error { background: #fed7d7; color: #742a2a; border: 1px solid #fc8181; }
.flash-success { background: #c6f6d5; color: #22543d; border: 1px solid #9ae6b4; }

.error { color: #c53030; padding: 0.5rem; font-size: 0.9rem; }

/* Footer */
footer {
    margin-top: 3rem;
    padding: 1.5rem 0;
    text-align: center;
    color: #a0aec0;
    border-top: 1px solid #e2e8f0;
}

/* Form stack (vertical fields) — quick-test form */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.form-stack label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.form-stack label > span {
    font-size: 0.95rem;
    color: #2d3748;
    font-weight: 500;
}
.form-stack label em {
    color: #c53030;
    font-style: normal;
}
.form-stack input,
.form-stack select,
.form-stack textarea {
    padding: 0.6rem 0.8rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    background: white;
}
.form-stack textarea {
    resize: vertical;
    min-height: 80px;
}
.form-stack input:focus,
.form-stack select:focus,
.form-stack textarea:focus {
    outline: 2px solid #4299e1;
    outline-offset: -1px;
    border-color: transparent;
}

.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.5rem 0;
}
.checkbox-label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Run page */
.run-header { margin-bottom: 1rem; }
.run-log {
    background: #1a202c;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    direction: ltr;
    text-align: left;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.status-run-queued { background: #e2e8f0; color: #4a5568; }
.status-run-running { background: #bee3f8; color: #2a4365; animation: pulse 1.5s ease-in-out infinite; }
.status-run-completed { background: #c6f6d5; color: #22543d; }
.status-run-failed { background: #fed7d7; color: #9b2c2c; }
.status-run-cancelled { background: #e2e8f0; color: #4a5568; }

/* Mobile */
@media (max-width: 700px) {
    .card { padding: 1rem; }
    .stats { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .main-nav { font-size: 0.85rem; gap: 0.4rem; flex-wrap: wrap; }
    .main-nav .badge { display: none; }
    .profiles-table { font-size: 0.85rem; }
    .profiles-table th, .profiles-table td { padding: 0.5rem 0.3rem; }
    .row-actions { flex-direction: column; }

    /* בנבט במובייל הופכים את ה-topbar למחזיק עם פרידה */
    .topbar .container { flex-direction: column; align-items: stretch; gap: 0.5rem; }
}

/* HTMX loading indicator */
.htmx-indicator {
    opacity: 0;
    transition: opacity 0.2s;
    margin-right: 0.5rem;
    color: #718096;
    font-size: 0.9em;
}
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* form-stack — קלאס נפוץ לטופסים אנכיים */
.form-stack { display: flex; flex-direction: column; gap: 1rem; }
.form-stack > label { display: flex; flex-direction: column; gap: 0.3rem; }
.form-stack > label > span {
    font-weight: 500;
    color: #2d3748;
    font-size: 0.95em;
}
.form-stack > label > span em {
    color: #c53030;
    font-style: normal;
    margin-left: 0.2em;
}
.form-stack input[type="text"],
.form-stack input[type="email"],
.form-stack input[type="password"],
.form-stack input[type="url"],
.form-stack input[type="number"],
.form-stack input[type="datetime-local"],
.form-stack input[type="time"],
.form-stack input[type="file"],
.form-stack textarea,
.form-stack select {
    padding: 0.6rem 0.8rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
    background: white;
}
.form-stack textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-stack input:focus,
.form-stack textarea:focus,
.form-stack select:focus {
    outline: none;
    border-color: #2b6cb0;
    box-shadow: 0 0 0 3px rgba(43,108,176,0.15);
}
.form-stack input:read-only,
.form-stack input:disabled {
    background: #f7fafc;
    color: #718096;
}

/* Checkbox label — אופקי עם כיתוב */
.checkbox-label {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"],
.checkbox-label input[type="radio"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* Form actions */
.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.btn-large { padding: 0.8rem 1.5rem; font-size: 1.05em; }

/* Flash messages */
.flash {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95em;
}
.flash-success { background: #f0fff4; color: #22543d; border: 1px solid #9ae6b4; }
.flash-error { background: #fff5f5; color: #9b2c2c; border: 1px solid #fc8181; }
.flash-info { background: #ebf8ff; color: #2c5282; border: 1px solid #90cdf4; }

/* Info card variant */
.info-card {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
}
.info-card h2 { color: #2d3748; }

/* Tables — generic */
table { border-collapse: collapse; width: 100%; }
table th { font-weight: 600; color: #4a5568; }

/* Badge / pill colors for status spans */
.status {
    display: inline-block;
    padding: 0.25em 0.6em;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
}

/* details/summary look — for collapsibles */
details summary { cursor: pointer; user-select: none; }
details summary::-webkit-details-marker { display: none; }

/* nicer scroll for long lists */
.scroll-y { max-height: 400px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 8px; }

/* Print friendly */
@media print {
    .topbar, .form-actions, .row-actions { display: none; }
}

/* ============================================================
   Accessibility + UX polish (added 2026-05-07)
   ============================================================ */

/* Focus ring ברור לכל אינטראקטיב — שיפור נגישות (WCAG) */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid #4f80ff;
    outline-offset: 2px;
}

/* טבלאות ארוכות במובייל — מאפשר scroll אופקי במקום לחפוץ העמוד */
@media (max-width: 700px) {
    .scroll-y table,
    .card table {
        font-size: 0.85em;
    }
    .card { padding: 1em; }
    h1 { font-size: 1.4em; }
    h2 { font-size: 1.15em; }
    .btn-large { width: 100%; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }
}

/* כפתורים מודפסים במייל / טפסים שמשתמשים מעתיקים */
.copy-target {
    user-select: all;
    cursor: text;
    background: #f0f4ff;
    padding: 0.3em 0.6em;
    border-radius: 4px;
    font-family: monospace;
    word-break: break-all;
}

/* טוקן/קישור קצר — נראה כמו pill */
.token-pill {
    display: inline-block;
    padding: 0.2em 0.6em;
    background: #e7f0ff;
    border-radius: 12px;
    font-family: monospace;
    font-size: 0.85em;
}

/* טרנזיציות חלקות לאינטראקטיב */
button, .btn, a.btn {
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
button:active, .btn:active {
    transform: translateY(1px);
}

