:root {
    --primary-blue: #0058D3;
    --primary-red: #FD0000;
    --text-color: #333333;
    --bg-color: #f4f7f6;
    --white: #ffffff;
    --gray-light: #e0e0e0;
    --gray-dark: #555555;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: var(--primary-blue);
    transition: color 0.2s ease-in-out;
}

a:hover {
    color: var(--primary-red);
}

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

/* Header */
.top-stripe {
    background-color: var(--primary-blue);
    height: 6px;
    width: 100%;
}

.main-header {
    background-color: var(--white);
    padding: 15px 0 0 0;
    box-shadow: var(--shadow);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    padding-bottom: 15px;
}

.logo {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.logo-top {
    display: flex;
    flex-direction: row;
    align-items: baseline;
}

.logo-inz {
    color: var(--primary-blue);
    font-size: 3.5rem;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
}

.logo-tri {
    color: var(--primary-red);
    font-size: 3.5rem;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
}

.logo-sub {
    font-size: 18px;
    color: var(--gray-dark);
    text-transform: uppercase;
    font-style: italic;
    letter-spacing: 1px;
    margin-top: 5px;
}

.header-links {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    color: var(--gray-dark);
}

.header-links a {
    color: var(--gray-dark);
}

.header-links a:hover {
    color: var(--primary-blue);
}

/* Main Layout */
.main-content {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 30px;
    margin-top: 30px;
    margin-bottom: 50px;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 30px;
    color: var(--primary-blue);
    cursor: pointer;
    padding: 5px;
}


/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.btn-add-ad {
    display: block;
    background-color: var(--primary-red);
    color: var(--white);
    text-align: center;
    padding: 12px;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, background-color 0.2s;
}

.btn-add-ad:hover {
    background-color: #d10000;
    color: var(--white);
    transform: translateY(-2px);
}

.categories-nav {
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.categories-nav a {
    padding: 12px 15px;
    border-bottom: 1px solid var(--gray-light);
    color: #444;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.categories-nav a:last-child {
    border-bottom: none;
}

.categories-nav a:hover,
.categories-nav a.active {
    background-color: var(--primary-blue);
    color: var(--white);
    padding-left: 20px;
    /* hover effect */
}

.search-box,
.user-box {
    background: var(--white);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.search-box h3,
.user-box h3 {
    font-size: 14px;
    background-color: #333;
    color: #fff;
    padding: 8px;
    margin: -15px -15px 15px -15px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.search-box form {
    display: flex;
}

.search-box input[type="text"] {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--gray-light);
    border-radius: 4px 0 0 4px;
    outline: none;
}

.search-box button {
    padding: 8px 12px;
    background-color: #666;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

/* Bottom stripe under header */
.bottom-stripe {
    background-color: var(--primary-red);
    height: 4px;
    width: 100%;
}

/* Lightbox styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.lightbox.zoomed {
    align-items: flex-start;
    justify-content: flex-start;
    overflow: auto;
    padding: 20px;
}

.lightbox img {
    max-width: 90%;
    max-height: 80%;
    border-radius: var(--border-radius);
    transition: max-width 0.2s, max-height 0.2s;
    cursor: zoom-in;
}

.lightbox.zoomed img {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
}

.lightbox .nav {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    transform: translateY(-50%);
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    user-select: none;
}

.lightbox .nav span {
    padding: 0 20px;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.lightbox-toolbar {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 15px;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    z-index: 1001;
}

.lightbox-toolbar span {
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.lightbox-toolbar span:hover {
    background: rgba(0, 0, 0, 0.8);
}

.footer-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    margin-top: 10px;
}

/* Content Area */
.content-area {
    background: var(--white);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.page-title {
    color: var(--primary-blue);
    border-bottom: 2px solid var(--gray-light);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

/* Typography inside content area (Markdown/Rich Text) */
.static-page-content h1,
.static-page-content h2,
.static-page-content h3,
.static-page-content h4 {
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    color: var(--text-color);
    font-weight: 600;
    line-height: 1.3;
}

.static-page-content h1 {
    font-size: 2.2rem;
    color: var(--primary-blue);
    border-bottom: 2px solid var(--gray-light);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 1em;
}

.static-page-content h2 {
    font-size: 1.7rem;
}

.static-page-content h3 {
    font-size: 1.4rem;
}

.static-page-content p {
    margin-bottom: 1.2em;
}

.static-page-content ul,
.static-page-content ol {
    margin-bottom: 1.2em;
    padding-left: 1.5em;
}

.static-page-content li {
    margin-bottom: 0.5em;
}

/* Posts List */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.post-item {
    /* Varianta B: svěle modrá + modrý brand pruh */
    background: linear-gradient(160deg, #f0f6ff 0%, #dbeafe 55%, #c7dcfc 100%);
    padding: 20px;
    border-radius: 3px 14px 3px 3px;
    display: flex;
    gap: 15px;
    border: none;
    border-top: 5px solid var(--primary-blue);
    border-left: 1px solid #b8d4f8;
    border-right: 1px solid #a8c8f6;
    margin-bottom: 25px;
    box-shadow:
        3px 5px 14px rgba(0, 88, 211, 0.10),
        0 1px 3px rgba(0, 0, 0, 0.07),
        inset 0 -2px 6px rgba(0, 88, 211, 0.05);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Ohnutý roh lepícího lístečku */
.post-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 18px 18px;
    border-color: transparent transparent #7baee8 transparent;
    border-radius: 0 0 3px 0;
}

/* Expirované inzeráty (červené podbarvení) */
.post-item.post-expired,
.ad-detail.post-expired {
    background: linear-gradient(160deg, #fff0f0 0%, #fedbdb 55%, #fcc7c7 100%);
    border-top-color: var(--primary-red);
    border-left-color: #f8b8b8;
    border-right-color: #f6a8a8;
}

.post-item.post-expired::after,
.ad-detail.post-expired::after {
    border-color: transparent transparent #e87b7b transparent;
}

/* Čekající inzeráty - viditelné pouze pro adminy */
.post-item.post-pending,
.ad-detail.post-pending {
    background: linear-gradient(160deg, #fff8f0 0%, #fdebd6 55%, #fcdcc7 100%);
    border-top-color: #e89c3c;
    border-left-color: #f8d4b8;
    border-right-color: #f6c8a8;
}

.post-item.post-pending::after,
.ad-detail.post-pending::after {
    border-color: transparent transparent #e8a87b transparent;
}

.pending-badge {
    display: inline-block;
    background: #e89c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 6px;
}

.post-item:hover {
    transform: translateY(-3px);
    border-left-color: var(--primary-blue);
    box-shadow:
        0 6px 20px rgba(253, 0, 0, 0.12),
        0 2px 6px rgba(0, 0, 0, 0.08);
}

.post-image {
    width: 150px;
    height: 150px;
    object-fit: contain;
    background-color: transparent;
    border-radius: 4px;
    flex-shrink: 0;
}

.post-content {
    flex-grow: 1;
    min-width: 0;
    /* Prevents flex items from overflowing their container */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.post-header {
    font-size: 12px;
    color: var(--gray-dark);
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.post-title {
    font-size: 17px;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 10px;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
    /* Na mobilu je .post-title flex položkou (.post-content má display: contents) —
       bez min-width by ho -webkit-box s dlouhým řádkem roztáhl přes šířku stránky */
    min-width: 0;
}

.post-title a {
    color: var(--text-color);
    text-decoration: none;
    /* Ořez textu inzerátu ve výpisu na max. 6 řádků (zalomení jako v detailu) */
    display: -webkit-box;
    -webkit-line-clamp: 8;
    line-clamp: 8;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-title a:hover {
    color: var(--primary-blue);
    text-decoration: none;
}

/* Odkaz "Celý inzerát..." — JS ho odkryje jen u inzerátů s oříznutým textem */
.post-more {
    display: inline-block;
    align-self: flex-start;
    margin: -4px 0 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-blue);
    text-decoration: none;
}

.post-more:hover {
    text-decoration: underline;
}

.post-more[hidden] {
    display: none;
}

.post-price {
    font-weight: 700;
    color: var(--primary-red);
    font-size: 18px;
    margin-bottom: 5px;
}

.post-contact {
    margin-top: 12px;
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    justify-content: flex-end;
}

.contact-item {
    font-size: 16px;
    font-weight: 500;
    color: #1e40af;
    background-color: #f0f6ff;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #b8d4f8;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ad-id-link {
    color: var(--primary-blue);
    text-decoration: underline;
    font-size: 17px;
    font-weight: 700;
    text-underline-offset: 3px;
}

.ad-id-link:hover {
    color: var(--primary-red);
    text-decoration: underline;
}

.post-header {
    font-size: 14px;
    color: var(--gray-dark);
    margin-bottom: 5px;
}

.ad-id-container {
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.post-date {
    font-size: 14px;
    font-weight: 400;
    color: var(--gray-dark);
}

/* Detail page */
.ad-detail {
    background: linear-gradient(160deg, #f0f6ff 0%, #dbeafe 55%, #c7dcfc 100%);
    padding: 25px;
    border-radius: 3px 14px 3px 3px;
    border-top: 5px solid var(--primary-blue);
    border-left: 1px solid #b8d4f8;
    border-right: 1px solid #a8c8f6;
    border-bottom: 1px solid transparent;
    box-shadow:
        3px 5px 14px rgba(0, 88, 211, 0.10),
        0 1px 3px rgba(0, 0, 0, 0.07),
        inset 0 -2px 6px rgba(0, 88, 211, 0.05);
    position: relative;
    margin-bottom: 30px;
}

.ad-detail::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 25px 25px;
    border-color: transparent transparent #7baee8 transparent;
    border-radius: 0 0 3px 0;
}

.detail-title {
    font-size: 24px;
    color: var(--primary-blue);
    margin-bottom: 15px;
}

.detail-meta {
    font-size: 14px;
    color: var(--gray-dark);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--gray-light);
}

.detail-image {
    max-width: 100%;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.detail-desc {
    font-size: 16px;
    line-height: 1.7;
    margin-bottom: 30px;
}

.detail-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-red);
    margin-bottom: 20px;
}

.detail-contact-box {
    background: var(--bg-color);
    padding: 20px;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-light);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
}

textarea.form-control {
    min-height: 150px;
    resize: vertical;
}

.btn-submit {
    background-color: var(--primary-red);
    color: var(--white);
    border: none;
    padding: 12px 25px;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-submit:hover {
    background-color: #d10000;
}

.main-footer {
    text-align: center;
    padding: 20px 0;
    color: var(--gray-dark);
    font-size: 14px;
}

#scrollTopBtn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#scrollTopBtn.show {
    opacity: 1;
    visibility: visible;
}

#scrollTopBtn:hover {
    background-color: var(--primary-red);
    transform: translateY(-3px);
}

@media (max-width: 768px) {
    .container {
        padding: 0 8px;
        /* Těsněji k okrajům obrazovky */
    }
    
    .main-header {
        padding: 0;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .content-area {
        padding: 0;
        background: transparent;
        box-shadow: none;
    }

    .logo {
        justify-content: center;
        align-items: flex-start;
        padding: 15px 0;
        
    }

    .logo-sub {
        font-size: 12px;
        margin-top: 0;
        
    }

    .mobile-menu-toggle {
        display: block;
        margin-left: auto;
        align-self: center;
    }

    .header-right {
        display: none;
    }

    .logo-inz {
        font-size: 2.5rem;
    }

    .logo-tri {
        font-size: 2.5rem;
    }

    .sidebar {
        display: flex !important;
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        visibility: hidden;
        transition: max-height 0.4s ease-in-out, opacity 0.4s ease-in-out, visibility 0.4s ease-in-out, margin 0.4s ease-in-out;
        margin-top: -20px;
    }

    .sidebar.active {
        max-height: 2000px;
        opacity: 1;
        visibility: visible;
        margin-top: 0;
        margin-bottom: 30px;
    }

    /* Mobilní layout lístečku — pouze rozložení, barvy zdědí ze základu */
    .post-item {
        flex-direction: column;
        align-items: stretch;
        padding: 14px 12px 16px;
        margin-left: 4px;
        margin-right: 4px;
        margin-bottom: 22px;
        gap: 0;
    }

    /* "Rozpustíme" kontejner obsahu, aby se z jeho prvků staly přímí potomci .post-item pro flex reordering */
    .post-content {
        display: contents;
    }

    /* Pořadí prvků na mobilu */
    .ad-id-container {
        order: 1;
        margin-bottom: 2px;
        gap: 2px 10px;
    }

    .post-header {
        order: 2;
        margin-bottom: 12px;
    }

    .post-item>a,
    .post-item>.no-photo {
        order: 3;
        align-self: center;
        margin-bottom: 15px;
    }

    .post-image {
        width: 100%;
        max-width: 300px;
        height: 200px;
    }

    .post-title {
        order: 4;
    }

    /* Stejné order jako .post-title — díky pořadí v DOM se zařadí hned za něj */
    .post-more {
        order: 4;
    }

    .gallery-thumbnails {
        order: 5;
    }

    .post-contact {
        order: 6;
    }

    /* Skryj "Bez fota" v mobilu — zbytečně zabírá místo */
    .no-photo {
        display: none !important;
    }
}

@media (max-width: 400px) {

    .logo-inz,
    .logo-tri {
        font-size: 1.7rem;
    }
}

@media (max-width: 768px) {
    .leaderboard-ad {
        display: none;
    }
}