:root {
    --bg: #0f172a;
    --panel: #111827;
    --card: #1f2937;
    --border: #374151;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #facc15;
    --green: #22c55e;
    --red: #ef4444;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, sans-serif;
    background: linear-gradient(135deg, #0f172a, #020617);
    color: var(--text);
}

/* Layout */
.admin-shell {
    max-width: 1300px;
    margin: 30px auto;
    padding: 20px;
}

.admin-content {
    width: 100%;
}

/* Topbar */
.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(17, 24, 39, 0.8);
    padding: 20px;
    border-radius: 14px;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.admin-title {
    margin: 0;
    font-size: 26px;
}

.admin-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

/* Buttons */
.button {
    background: var(--accent);
    color: #000;
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.button.secondary {
    background: #374151;
    color: #fff;
}

.danger {
    background: var(--red);
    border: none;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
}

/* Cards */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: var(--card);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-card strong {
    font-size: 26px;
    display: block;
}

.stat-card span {
    color: var(--muted);
}

/* Panel */
.panel {
    background: rgba(17, 24, 39, 0.85);
    border-radius: 14px;
    padding: 20px;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

/* Table */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #020617;
}

th,
td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

/* Status */
.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
}

.badge.ok {
    background: rgba(34,197,94,0.2);
    color: var(--green);
}

.badge.off {
    background: rgba(239,68,68,0.2);
    color: var(--red);
}

/* Actions */
.inline-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Alerts */
.alert {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.alert.success {
    background: rgba(34,197,94,0.2);
    color: var(--green);
}

.alert.error {
    background: rgba(239,68,68,0.16);
    color: #fecaca;
    border: 1px solid rgba(239,68,68,0.35);
}

/* Footer hint */
.code-box {
    font-size: 13px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

/* FORM */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Blocks */
.block {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
}

.block h3 {
    margin: 0 0 12px;
    font-size: 16px;
}

/* Inputs */
.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

input,
select,
textarea {
    background: #020617;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
}

textarea {
    display: block;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Grid */
.lang-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.tab-btn {
    padding: 6px 12px;
    border-radius: 6px;
    background: #374151;
    cursor: pointer;
    font-size: 13px;
}

.tab-btn.active {
    background: var(--accent);
    color: #000;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Editor */
.editor-block {
    display: flex;
    flex-direction: column;
}

/* Actions */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.form-actions button {
    background: var(--accent);
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* Messages layout */
.messages-grid {
    display: grid;
    gap: 16px;
}

/* Card */
.message-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    transition: 0.2s;
}

.message-card:hover {
    transform: translateY(-2px);
}

/* Unread highlight */
.message-card.unread {
    border-left: 3px solid var(--accent);
}

/* Header */
.message-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.message-name {
    font-weight: 600;
    font-size: 15px;
}

/* Meta */
.message-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

/* Body */
.message-body {
    margin: 10px 0 14px;
    line-height: 1.5;
}

/* Actions */
.message-actions {
    display: flex;
    gap: 8px;
}

/* Small buttons */
.button.small {
    padding: 6px 10px;
    font-size: 12px;
}

.danger.small {
    padding: 6px 10px;
    font-size: 12px;
}

/* LOGIN PAGE */
.login-wrap {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #1e293b, #020617);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 20px;
}

.login-header h1 {
    margin: 0;
    font-size: 24px;
}

.login-header p {
    margin-top: 6px;
    font-size: 13px;
    color: var(--muted);
}

.login-card input {
    width: 100%;
}

.login-btn {
    margin-top: 10px;
    background: var(--accent);
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.login-btn:hover {
    transform: translateY(-1px);
}

.login-footer {
    text-align: center;
    margin-top: 14px;
    font-size: 12px;
    color: var(--muted);
}

/* Gallery admin */
.gallery-admin {
    max-width: 900px;
    margin: 40px auto;
    padding: 20px;
}

.ga-card {
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: 25px;
    border: 1px solid rgba(255,255,255,0.08);
}

.ga-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 15px;
}

.ga-upload {
    border: 2px dashed rgba(255,255,255,0.2);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
}

.ga-upload:hover {
    border-color: #f1c40f;
    background: rgba(241,196,15,0.05);
}

.ga-upload input {
    display: none;
}

.ga-upload-text {
    font-size: 14px;
    color: #aaa;
}

.ga-btn {
    margin-top: 15px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: #f1c40f;
    color: #000;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.ga-btn:hover {
    background: #ffd84d;
}

.ga-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    margin-top: 25px;
}

.ga-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #111;
}

.ga-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.ga-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    opacity: 0;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ga-item:hover .ga-overlay {
    opacity: 1;
}

.ga-delete {
    background: #e74c3c;
    border: none;
    padding: 6px 10px;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
}

@media (max-width: 600px) {
    .ga-upload {
        padding: 20px;
    }
}

/* === GALLERY === */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.gallery-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.gallery-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.gallery-actions {
    position: absolute;
    bottom: 6px;
    right: 6px;
}

.gallery-item:hover {
    transform: translateY(-2px);
    transition: 0.2s;
}

/* File/code editor */

.editor-shell {
    max-width: 1560px;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.editor-layout {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.editor-sidebar {
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 120px);
    overflow: auto;
}

.editor-search-wrap {
    margin-bottom: 14px;
}

.editor-search-wrap input {
    width: 100%;
}

.editor-group {
    margin-bottom: 18px;
}

.editor-group-title {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.editor-file {
    display: block;
    padding: 9px 10px;
    margin-bottom: 5px;
    color: var(--text);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.03);
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.editor-file:hover,
.editor-file.active {
    border-color: rgba(250, 204, 21, 0.55);
    background: rgba(250, 204, 21, 0.12);
}

.editor-main h2 {
    margin: 0;
    font-size: 20px;
    overflow-wrap: anywhere;
}

.editor-main p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.editor-headline {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 14px;
}

#codeEditor,
.code-content-editor {
    width: 100%;
    height: calc(100vh - 170px);
    min-height: 760px;
    resize: vertical;
    padding: 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #050816;
    color: #e5e7eb;
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    tab-size: 4;
}

/* fullscreen */
body.editor-fullscreen {
    overflow: hidden;
}

body.editor-fullscreen .editor-sidebar,
body.editor-fullscreen .editor-help {
    display: none !important;
}

body.editor-fullscreen .editor-shell,
body.editor-fullscreen .editor-layout,
body.editor-fullscreen .editor-main,
body.editor-fullscreen form {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

body.editor-fullscreen .editor-layout {
    display: block;
}

body.editor-fullscreen .editor-main {
    border: 0;
    border-radius: 0;
    min-height: 100vh;
}

body.editor-fullscreen #codeEditor {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    padding: 24px;
    font-size: 15px;
    line-height: 1.7;
}

.editor-help {
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}

/* responsive */
@media (max-width: 900px) {

    .admin-topbar,
    .editor-headline {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .editor-layout {
        grid-template-columns: 1fr;
    }

    .editor-sidebar {
        position: static;
        max-height: 320px;
        overflow: auto;
    }

    #codeEditor,
    .code-content-editor {
        min-height: 620px;
        font-size: 13px;
    }
}

/* =========================
   MONACO EDITOR
========================= */

.monaco-editor-box{
    width:100%;
    height:850px;

    border-radius:14px;
    overflow:hidden;

    border:1px solid var(--border);

    background:#050816;

    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,0.02),
        0 10px 35px rgba(0,0,0,0.35);

    transition:0.2s;
}

.monaco-editor-box:hover{
    border-color:rgba(250,204,21,0.25);
}

.monaco-editor,
.monaco-editor-background,
.monaco-editor .margin{
    background:#050816 !important;
}

/* Tabs editor spacing */

.tab-content{
    margin-top:10px;
}

/* block spacing */

.block .monaco-editor-box{
    margin-top:10px;
}

/* editor top spacing */

.editor-toolbar{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:10px;

    margin-bottom:10px;
}

/* status */

.editor-status{
    font-size:12px;
    color:var(--muted);
}

/* fullscreen mode */

body.editor-fullscreen{
    overflow:hidden;
}

body.editor-fullscreen .admin-topbar,
body.editor-fullscreen .tabs,
body.editor-fullscreen .code-box,
body.editor-fullscreen .form-actions{
    display:none !important;
}

body.editor-fullscreen .admin-shell,
body.editor-fullscreen .admin-content,
body.editor-fullscreen .panel,
body.editor-fullscreen .block{
    width:100%;
    max-width:100%;
    margin:0;
    padding:0;

    border:none;
    border-radius:0;

    background:#050816;
}

body.editor-fullscreen .monaco-editor-box{
    width:100%;
    height:100vh;
    border:none;
    border-radius:0;
}

/* Monaco scrollbar */

.monaco-scrollable-element > .scrollbar > .slider{
    border-radius:10px;
}

/* Better font rendering */

.monaco-editor *{
    font-family:
        Consolas,
        Monaco,
        "Courier New",
        monospace !important;
}

/* Responsive */

@media (max-width: 900px){

    .monaco-editor-box{
        height:700px;
    }
}

@media (max-width: 600px){

    .monaco-editor-box{
        height:600px;
    }
}