* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f1e8;
    color: #333;
    direction: rtl;
}

/* Two independent widths, per request: the top menu is wider than the jokes list below it. */
.page-wrap {
    width: 100%;
}

.top-header {
    background: #ffcc33;
    box-shadow: 0 2px 4px rgba(0,0,0,.15);
    border-radius: 0 0 8px 8px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 16px;
}
.cat-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    direction: rtl;              /* ראשי first in markup = rightmost on screen */
    justify-content: flex-start; /* flex-start in RTL = packed to the right */
}
.cat-btn {
    display: inline-block;
    padding: 3px;
    border-radius: 8px;
    line-height: 0;
    background-color: #ff6600;   /* orange when idle */
    transition: background-color .12s ease;
}
.cat-btn img { display: block; width: 72px; height: 72px; object-fit: contain; }
.cat-btn:hover, .cat-btn.active {
    background-color: #8e44ad;   /* purple when hovered / current category */
}
.cat-btn.add-btn { margin-right: 6px; }

.toolbar {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.sort-box { font-size: 18px; }
.sort-box select {
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #ccc;
}
.cat-title { font-size: 20px; font-weight: bold; }

.search-form { display: flex; align-items: center; }
.search-input-wrap { position: relative; display: inline-block; }
.search-input {
    padding: 8px 40px 8px 38px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 15px;
    background: #fff url('img/icon-search.png') no-repeat right 10px center;
    background-size: 18px 18px;
}
.search-submit {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    background: #ff6600;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
.search-submit:hover { background: #8e44ad; }
.arrow-glyph { display: inline-block; transform: scaleX(0.55); }

#jokesList { max-width: 900px; margin: 0 auto; padding: 0 16px; }
#loadMoreSentinel, #loadingIndicator { max-width: 900px; margin: 0 auto; }
.joke-card {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.joke-text { font-size: 17px; line-height: 1.5; margin-bottom: 10px; }

.joke-votes { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; direction: ltr; justify-content: flex-end; }
.vote-unit { display: flex; flex-direction: row-reverse; align-items: center; gap: 2px; }
.vote-btn {
    border: none;
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    padding: 0;
    width: 44px;
    height: 44px;
    cursor: pointer;
}

.vote-btn.like { background-image: url('img/thumb-like.png'); }
.vote-btn.like:hover, .vote-btn.like.voted { background-image: url('img/thumb-like-hover.png'); }

.vote-btn.dislike { background-image: url('img/thumb-dislike.png'); }
.vote-btn.dislike:hover, .vote-btn.dislike.voted { background-image: url('img/thumb-dislike-hover.png'); }

.vote-count { font-size: 15px; font-weight: bold; }
.dislike-count { color: #d8322a; }
.like-count { color: #4caf1f; }

.joke-meta { font-size: 13px; color: #888; }
.no-jokes { text-align: center; padding: 40px; color: #888; }

#loadingIndicator { text-align: center; padding: 16px; color: #888; }

.add-form-wrap { max-width: 600px; margin: 20px auto; padding: 0 16px; }
.add-form-wrap input[type=text], .add-form-wrap textarea, .add-form-wrap select { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; font-size: 15px; }
.add-form-wrap button { padding: 10px 20px; background: #4caf50; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 15px; }
.error { color: #c0392b; margin-bottom: 10px; }
.field-error { display: block; color: #c0392b; font-size: 15px; margin-top: 2px; min-height: 18px; }
.successful { color: #2e7d32; margin-bottom: 10px; font-weight: bold; }

@media (max-width: 600px) {
    .cat-btn img { width: 48px; height: 48px; }
    .cat-nav { justify-content: center; }
    .toolbar { flex-direction: column; align-items: flex-start; }
}
