/* =========================================
   1. Global Reset & Typography
   ========================================= */
* {
    box-sizing: border-box;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 0.5rem 0;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: "Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, sans-serif;
    color: #333;
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 100%;
}

ul { list-style: none; padding: 0; margin: 0; }

a {
    text-decoration: none;
    color: #07f;
}

a:hover {
    text-decoration: underline;
}

/* =========================================
   2. Shared Layout Structure
   ========================================= */

.container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    display: grid;
    min-height: 100%;
    min-width: 0;
}

/* Header & Footer: Shared "Bar" Styles */
body > header,
body > footer {
    border-bottom: 1px solid #ccc;
    padding: 1rem 1.5rem;
    background: #fff;
    width: 100%;
}

body > footer {
    border-bottom: none;
    border-top: 1px solid #ccc;
    text-align: center;
}

body > footer p {
    margin: 0;
}

/* Navigation inside Header */
body > header > nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

body > header > nav > #logo {
    font-weight: bold;
    font-size: 1.17rem; /* Matches standard H3 size */
}

body > header > nav > #logo a {
    color: #000;
}

body > header > nav > ul {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.lang-switcher {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lang-switcher a {
    display: flex;
    align-items: center;
    gap: 5px;
}

.lang-switcher img {
    display: block;
    border: 1px solid #eee;
    vertical-align: middle;
}

/* Main Content Area */
main {
    width: 100%;
    display: grid;
    padding: 2rem 0;
    max-width: 100%;
}

/* =========================================
   3. Sidebar System (Unified)
   ========================================= */

aside {
    display: flex;
    flex-direction: column;
    min-width: 250px;
    width: 250px;
}

.sidebar-box {
    padding: 1.5rem;
}

.sidebar-box h3 {
    margin-top: 0;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.5rem;
    font-size: 1.1rem;
}

.sidebar-box ul li {
    margin-bottom: 0.5rem;
}

.sidebar-box ul li a {
    display: block;
    padding: 0.5rem 0;
    white-space: nowrap; /* Prevent nav links from wrapping */
}

/* VARIANT 1: Box Style (Default/Standard) */
.layout-standard .sidebar-box {
    background: #eee;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin: 1.5rem;
}

/* VARIANT 2: Admin Style (Clean) */
.layout-admin aside {
    background: #eee;
    min-height: 100%;
}

.layout-admin .sidebar-left  { border-right: 1px solid #ccc; }
.layout-admin .sidebar-right { border-left: 1px solid #ccc; }

.layout-admin .sidebar-box {
    background: transparent;
    border: none;
    margin: 0;
    border-radius: 0;
}

/* =========================================
   4. Grid Systems
   ========================================= */

.grid-2-col-right { grid-template-columns: 1fr 250px; }
.grid-2-col-left  { grid-template-columns: 250px 1fr; }
.grid-3-col       { grid-template-columns: 250px 1fr 250px; }

.content-area {
    padding: 2rem 1.5rem;
    min-width: 0; /* CRITICAL: Allows area to shrink so table-responsive works */
}

/* Utility / Back Links */
.back-link,
.content-area > a:first-child,
.container > a:first-child {
    display: inline-block;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* Session Messages & Alerts */
.msg {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.msg-success { background: #eee; border-color: #ccc; }
.msg-error { background: #fee; border-color: #d00; color: #d00; }

/* Generic Confirmation Box */
.confirm-box {
    max-width: 500px;
    margin: 2rem auto;
    text-align: center;
}

/* =========================================
   5. Reusable UI Components
   ========================================= */
.table-responsive {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    min-width: 600px; /* Ensures table doesn't squish too much, triggering scroll */
}
th, td { 
    padding: 12px 8px; 
    border: 1px solid #ccc; 
    text-align: left; 
    white-space: nowrap; /* Prevent text wrapping */
}
th { background: #eee; }

/* End of Reusable UI Components */

/* Forms */
label { 
    display: block; 
    margin-bottom: 0.3rem; 
    font-weight: bold; 
    font-size: 0.85rem; /* Smaller font size for labels */
}

/* Global Input Fix: Exclude radios and checkboxes from huge widths */
input:not([type="radio"]):not([type="checkbox"]), 
textarea, 
select { 
    width: 100%; 
    padding: 0.5rem; 
    margin-bottom: 1rem; 
    border: 1px solid #ccc; 
    font-family: inherit; 
}

button, .btn { 
    display: inline-block; 
    padding: 0.5rem 1rem; 
    background-color: #eee; 
    border: 1px solid #ccc; 
    cursor: pointer; 
    color: #333; 
    text-decoration: none; 
}

/* CSS Tabs System */
.tabs { 
    display: flex; 
    flex-wrap: wrap; /* CRITICAL: Allows content to wrap below buttons */
    margin-bottom: 20px; 
}

.tabs input[type="radio"] { 
    display: none; /* Keep them hidden */
}

.tab-button { 
    padding: 10px 20px; 
    cursor: pointer; 
    border: 1px solid #ccc; 
    border-bottom: none; 
    background: #eee; 
    margin-right: 5px; 
}

.tab-content { 
    border: 1px solid #ccc; 
    padding: 20px; 
    display: none; 
    width: 100%; 
    order: 1; /* Move content after buttons in flex flow */
}

#tab-en:checked ~ .label-en, 
#tab-ru:checked ~ .label-ru { 
    background: #fff; 
    font-weight: bold; 
    border-bottom: 1px solid #fff; 
    margin-bottom: -1px; 
    z-index: 1; 
}

#tab-en:checked ~ .content-en, 
#tab-ru:checked ~ .content-ru { 
    display: block; 
}

/* Manual Slug Utility */
.manual-slug-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: -10px;
    margin-bottom: 15px;
}

.manual-slug-wrap input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.manual-slug-wrap label {
    margin: 0;
    font-weight: normal;
}