/* ============================================================
   ООО "ПС" Portal — main stylesheet
   ============================================================ */

:root {
    --red:       #d32f2f;
    --red-dark:  #b71c1c;
    --blue:      #007bff;
    --blue-dark: #0056b3;
    --bg:        #f4f4f4;
    --text:      #333;
    --border:    #e0e0e0;
    --card-bg:   #fff;
    --shadow:    0 2px 5px rgba(0,0,0,.10);
}

/* ---- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--blue); }
a:hover { text-decoration: underline; }

/* ---- Layout ----------------------------------------------- */
.page-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

/* ---- Header ----------------------------------------------- */
header {
    width: 100%;
}
.header-content {
    width: 100%;
    min-height: 80px;
    background-image: url('/images/polosa.png');
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}
.logo-link {
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    text-decoration: none;
}
.user-greeting {
    color: #fff;
    font-size: 14px;
    margin-right: 8px;
}
.buttons-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ---- Buttons ---------------------------------------------- */
.btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    display: inline-block;
    transition: background-color .2s, border-color .2s;
    line-height: 1.4;
}
.btn-red {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}
.btn-red:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-blue {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}
.btn-blue:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-outline {
    background: rgba(0,0,0,.4);
    color: #fff;
    border-color: rgba(255,255,255,.4);
}
.btn-outline:hover { background: rgba(0,0,0,.6); border-color: rgba(255,255,255,.6); }
.btn-admin {
    background: #fff;
    color: var(--red);
    border-color: #fff;
}
.btn-admin:hover { background: #f5f5f5; }
.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
    font-size: 13px;
    padding: 5px 12px;
}
.btn-danger:hover { background: var(--red-dark); }
.btn-sm {
    font-size: 13px;
    padding: 5px 12px;
}
.btn-full { width: 100%; text-align: center; }

/* ---- Site title ------------------------------------------- */
.site-title {
    text-align: center;
    padding: 20px 0;
    font-size: 22px;
    font-weight: bold;
    color: var(--text);
}

/* ---- Cards / blocks --------------------------------------- */
.card {
    background: var(--card-bg);
    margin-bottom: 20px;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.card h2 {
    text-align: center;
    color: var(--red);
    margin-top: 0;
}

/* ---- News accordion --------------------------------------- */
.news-item {
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}
.news-item:last-child { border-bottom: none; }
.news-title {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    padding: 14px 0 10px;
    cursor: pointer;
    font-size: 17px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.news-title strong { color: var(--red); }
.news-arrow::after {
    content: '▼';
    font-size: 14px;
    transition: transform .3s;
    display: inline-block;
}
.news-item.open .news-arrow::after { transform: rotate(180deg); }
.news-content {
    display: none;
    padding: 0 0 14px 0;
    color: #555;
    line-height: 1.6;
}
.news-item.open .news-content { display: block; }

/* ---- Section links ---------------------------------------- */
.links-block {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 20px 0 4px;
    flex-wrap: wrap;
}
.link-item {
    padding: 14px 28px;
    background: var(--blue);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 16px;
    transition: background-color .2s;
}
.link-item:hover { background: var(--blue-dark); color: #fff; }

/* ---- File list -------------------------------------------- */
.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.file-list li {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.file-list li:last-child { border-bottom: none; }
.file-list a {
    color: var(--blue);
    text-decoration: none;
    font-size: 15px;
}
.file-list a:hover { text-decoration: underline; }
.file-locked {
    color: #999;
    font-size: 15px;
}
.file-icon { font-size: 20px; }
.file-lock-hint {
    font-size: 12px;
    color: #999;
    margin-left: 4px;
}

/* ---- Subpage header (back button) ------------------------- */
.subpage-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.back-link {
    color: var(--blue);
    text-decoration: none;
    font-size: 14px;
}
.back-link:hover { text-decoration: underline; }
.subpage-header h1 {
    margin: 0;
    font-size: 22px;
    color: var(--text);
}

/* ---- Reviews ---------------------------------------------- */
.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.review-card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.review-photo {
    width: 100%;
    height: 180px;
    object-fit: cover;
}
.review-body {
    padding: 12px;
}
.stars { color: #f5a623; font-size: 18px; letter-spacing: 2px; }
.review-comment { font-size: 14px; color: #555; margin: 6px 0; }
.review-meta { font-size: 12px; color: #999; }

/* ---- Star rating input ------------------------------------ */
.star-rating { display: flex; gap: 4px; }
.star-rating input[type=radio] { display: none; }
.star-rating label {
    font-size: 28px;
    color: #ccc;
    cursor: pointer;
    transition: color .15s;
}
.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label { color: #f5a623; }
.star-rating { flex-direction: row-reverse; justify-content: flex-end; }

/* ---- Review form ------------------------------------------ */
.review-form-wrap { margin-top: 20px; }
.no-reviews { color: #999; text-align: center; padding: 20px 0; }

/* ---- Forms ------------------------------------------------ */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 4px;
    color: #555;
}
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group input[type=datetime-local],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ---- Flash messages --------------------------------------- */
.flash {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 14px;
}
.flash-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.flash-error   { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }

/* ---- Modal ------------------------------------------------ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-box {
    background: #fff;
    border-radius: 10px;
    padding: 28px 32px;
    width: 100%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-box h2 { margin-top: 0; color: var(--text); }
.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #888;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-switch { font-size: 13px; text-align: center; margin-top: 12px; }

/* ---- Page-level auth forms (login.php / register.php) ------ */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 16px;
}
.auth-box {
    background: #fff;
    border-radius: 10px;
    padding: 32px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}
.auth-box h1 { margin-top: 0; font-size: 22px; }

/* ---- Footer ----------------------------------------------- */
footer { margin-top: 40px; }
.footer-overlay {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 24px 0;
    text-align: center;
}
.footer-text p { margin: 6px 0; color: #555; font-size: 14px; }
.footer-text a { color: var(--red); text-decoration: none; }
.footer-text a:hover { text-decoration: underline; }

/* ---- Admin layout ----------------------------------------- */
.admin-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 40px;
}
.admin-header {
    background: #263238;
    color: #fff;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}
.admin-header a { color: #cfd8dc; text-decoration: none; font-size: 14px; }
.admin-header a:hover { color: #fff; }
.admin-nav {
    background: #37474f;
    display: flex;
    gap: 2px;
    padding: 0 20px;
    flex-wrap: wrap;
}
.admin-nav a {
    color: #cfd8dc;
    text-decoration: none;
    padding: 10px 14px;
    font-size: 14px;
    display: block;
    transition: background .2s;
}
.admin-nav a:hover,
.admin-nav a.active { background: #263238; color: #fff; }

.admin-section { margin-top: 28px; }
.admin-section h2 { font-size: 20px; margin-bottom: 16px; border-bottom: 2px solid var(--border); padding-bottom: 8px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 18px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-card .stat-num { font-size: 36px; font-weight: bold; color: var(--blue); }
.stat-card .stat-label { font-size: 13px; color: #777; margin-top: 4px; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    font-size: 14px;
}
.admin-table th {
    background: #eceff1;
    padding: 10px 14px;
    text-align: left;
    font-weight: bold;
    color: #555;
    border-bottom: 1px solid var(--border);
}
.admin-table td {
    padding: 9px 14px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #fafafa; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
}
.badge-pending  { background: #fff3e0; color: #e65100; }
.badge-approved { background: #e8f5e9; color: #2e7d32; }
.badge-rejected { background: #ffebee; color: #c62828; }

.tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.tab-btn {
    padding: 8px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: #777;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .2s;
}
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: bold; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.upload-form {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.upload-form h3 { margin-top: 0; font-size: 16px; }

/* ---- Review thumbnail in admin ---------------------------- */
.thumb-img { width: 60px; height: 45px; object-fit: cover; border-radius: 4px; }

/* ---- Pagination ------------------------------------------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pagination a, .pagination span {
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    color: var(--blue);
    text-decoration: none;
}
.pagination .current { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---- Category form grid ----------------------------------- */
.cat-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 100px;
    gap: 12px;
    align-items: end;
}
.cat-edit-flex {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.cat-edit-flex .sort-field {
    width: 100px;
    flex-shrink: 0;
}
.cat-edit-flex .name-field { flex: 2; min-width: 140px; }
@media (max-width: 600px) {
    .cat-form-grid { grid-template-columns: 1fr; }
    .cat-edit-flex { flex-direction: column; align-items: stretch; }
    .cat-edit-flex .sort-field { width: 100%; }
}

/* ---- Table scroll wrapper (filled by JS) ------------------ */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Responsive: admin panel ------------------------------ */
@media (max-width: 768px) {
    .admin-wrap { padding: 0 8px 24px; }

    .admin-header {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 12px;
        min-height: auto;
    }

    .admin-nav {
        padding: 0 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }
    .admin-nav::-webkit-scrollbar { display: none; }
    .admin-nav a {
        white-space: nowrap;
        padding: 10px 10px;
        font-size: 13px;
    }

    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab-btn { white-space: nowrap; padding: 8px 14px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .upload-form { padding: 14px; }

    .admin-section h2 { font-size: 17px; }
}

@media (max-width: 480px) {
    .admin-header { font-size: 13px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card .stat-num { font-size: 28px; }
}

/* ---- Responsive: public header ---------------------------- */
@media (max-width: 600px) {
    .header-content {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 14px;
        min-height: auto;
    }
    .buttons-container { gap: 6px; }
    .btn { padding: 6px 12px; font-size: 13px; }
    .site-title { font-size: 17px; padding: 14px 0; }
    .links-block { gap: 10px; }
    .link-item { padding: 12px 16px; font-size: 14px; }
    .page-wrap { padding: 0 10px 30px; }
}
