/* ============================================================
   Central Admin Panel — Fully Responsive CSS
   Mobile-first · Tablet · Desktop · Large screens
   ============================================================ */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --text: #334155;
    --muted: #64748b;
    --sidebar-w: 260px;
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f1f5f9;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video { max-width: 100%; height: auto; }

/* ============================================================
   LAYOUT — Desktop default, mobile overrides below
   ============================================================ */

.wrapper {
    display: block;
    min-height: 100vh;
    position: relative;
}

/* --- Mobile top bar --- */
.mobile-bar {
    display: none;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--dark);
    color: #fff;
    padding: 0.65rem 1rem;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.menu-toggle {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    font-size: 1.35rem;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.menu-toggle:active { background: rgba(255,255,255,0.2); }

.mobile-title {
    font-weight: 600;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Overlay --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 250;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--dark);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 300;
    -webkit-overflow-scrolling: touch;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 1.35rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    padding-right: 2rem;
}

.sidebar-header small {
    display: block;
    margin-top: 0.15rem;
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 0.75rem;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 1.15rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    line-height: 1;
}

.sidebar-close:active { background: rgba(255,255,255,0.2); }

.sidebar-nav {
    padding: 0.75rem 0 2rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.35rem;
    color: rgba(255,255,255,0.78);
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    font-size: 0.95rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    text-decoration: none;
}

/* --- Main content --- */
.main-content {
    margin-left: var(--sidebar-w);
    padding: 1.5rem 2rem;
    min-height: 100vh;
    width: auto;
    max-width: 100%;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.3;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: #fafafa;
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.15rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-left: 4px solid var(--primary);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card.info    { border-left-color: var(--info); }

.stat-card .label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.stat-card .value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--dark);
}

/* Forms */
.form-group {
    margin-bottom: 1.15rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; opacity: 0.92; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-info      { background: var(--info); color: #fff; }
.btn-secondary { background: #64748b; color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

.action-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

table th,
table td {
    padding: 0.7rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

table tr:hover { background: #f8fafc; }

/* Badge */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #e2e8f0; color: #475569; }

/* Alert */
.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.15rem;
    font-size: 0.92rem;
    word-break: break-word;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* Site cards */
.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.15rem;
}

.site-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.site-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.site-card-header {
    padding: 1.15rem;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
}

.site-card-header h3 {
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}

.site-card-header a {
    color: rgba(255,255,255,0.85);
    font-size: 0.82rem;
    word-break: break-all;
}

.site-card-body { padding: 1.15rem; }

.site-card-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.85rem;
}

/* Code box */
.code-box {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.75rem 1rem;
    padding-right: 4.5rem;
    border-radius: 8px;
    font-family: ui-monospace, 'Courier New', monospace;
    font-size: 0.82rem;
    word-break: break-all;
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    padding: 0.25rem 0.55rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.72rem;
}

.copy-btn:hover { background: rgba(255,255,255,0.22); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.show { display: flex; }

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.modal-header {
    padding: 1.15rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { font-size: 1.15rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--muted);
}

.modal-body { padding: 1.15rem; }

.modal-footer {
    padding: 0.9rem 1.15rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.15rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.15rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    padding: 0.6rem 1.1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

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

/* API toolbar */
.api-toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    align-items: center;
}

.api-toolbar input[type=text],
.api-toolbar input[type=number],
.api-toolbar select {
    padding: 0.4rem 0.55rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    max-width: 100%;
}

/* Result box */
.result-box {
    background: #0f172a;
    color: #94a3b8;
    padding: 1rem;
    border-radius: 8px;
    font-family: ui-monospace, monospace;
    font-size: 0.82rem;
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.result-box.success { border-left: 4px solid var(--success); }
.result-box.error   { border-left: 4px solid var(--danger); }

/* Login */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    padding: 1rem;
}

.login-box {
    background: #fff;
    padding: 2.25rem;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-header h1 {
    font-size: 1.65rem;
    color: var(--dark);
}

.login-header p {
    color: var(--muted);
    margin-top: 0.25rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.35rem;
    color: var(--muted);
}

/* ============================================================
   DEPOSIT METHODS
   ============================================================ */

.methods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.method-card {
    background: #fff;
    border: 1px solid #e8e8ef;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    display: flex;
    flex-direction: column;
    gap: .75rem;
    transition: box-shadow .15s, transform .15s;
}

.method-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,.08);
    transform: translateY(-1px);
}

.method-head {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.method-logo {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    object-fit: contain;
    background: #f5f6fa;
    border-radius: 10px;
    border: 1px solid #eee;
    padding: 4px;
}

.method-logo.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #bbb;
}

.method-title { flex: 1; min-width: 0; }

.method-title .name {
    font-weight: 700;
    font-size: 1.05rem;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.method-title .id {
    font-size: .72rem;
    color: #999;
    margin-top: 2px;
}

.method-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .35rem .6rem;
    font-size: .85rem;
    padding: .6rem;
    background: #fafbfd;
    border-radius: 8px;
}

.method-info dt {
    color: #888;
    font-weight: 500;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.method-info dd {
    margin: 0;
    color: #333;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: .82rem;
    word-break: break-all;
}

.method-info dd.empty { color: #ccc; font-style: italic; font-family: inherit; }

.method-status-row {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.status-toggle {
    flex: 1;
    min-width: 100px;
    border: 0;
    padding: .55rem .7rem;
    border-radius: 8px;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    transition: filter .15s, transform .1s;
    color: #fff;
}

.status-toggle:hover  { filter: brightness(1.08); }
.status-toggle:active { transform: scale(.97); }
.status-toggle.on  { background: linear-gradient(135deg,#22c55e,#16a34a); }
.status-toggle.off { background: linear-gradient(135deg,#94a3b8,#64748b); }

.status-toggle .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: rgba(255,255,255,.9);
}

.status-toggle .lbl {
    font-size: .68rem;
    opacity: .85;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.method-actions {
    display: flex;
    gap: .5rem;
    margin-top: auto;
}

.method-actions .btn { flex: 1; }

.method-edit {
    background: #f8f9fb;
    border-radius: 10px;
    padding: .85rem;
    margin-top: .5rem;
    display: flex;
    flex-direction: column;
    gap: .65rem;
}

.method-edit label {
    font-size: .78rem;
    color: #555;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.method-edit input,
.method-edit select {
    padding: .5rem .6rem;
    border: 1px solid #dfe1e8;
    border-radius: 7px;
    font-size: .88rem;
    background: #fff;
    width: 100%;
    font-family: inherit;
}

.method-edit input:focus,
.method-edit select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.method-edit .row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .65rem;
}

.method-create-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .75rem;
    align-items: end;
}

.method-create-form label {
    font-size: .78rem;
    color: #555;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.method-create-form input,
.method-create-form select {
    padding: .55rem .65rem;
    border: 1px solid #dfe1e8;
    border-radius: 7px;
    font-size: .88rem;
    width: 100%;
    font-family: inherit;
}

.method-create-form .full { grid-column: 1 / -1; }
.method-create-form button { grid-column: 1 / -1; padding: .7rem; }

.methods-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #999;
}

.methods-empty .icon { font-size: 2.5rem; margin-bottom: .5rem; }

.methods-toolbar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: .75rem;
}

/* ============================================================
   RESPONSIVE — TABLET ≤ 1024px
   ============================================================ */
@media (max-width: 1024px) {
    .main-content {
        padding: 1.25rem 1.35rem;
    }

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

    .site-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

/* ============================================================
   RESPONSIVE — MOBILE ≤ 768px  (hamburger menu)
   ============================================================ */
@media (max-width: 768px) {

    /* Show mobile top bar */
    .mobile-bar {
        display: flex;
    }

    /* Hide sidebar off-canvas by default */
    .sidebar {
        transform: translateX(-100%);
        width: min(280px, 85vw);
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Full-width main content */
    .main-content {
        margin-left: 0 !important;
        padding: 1rem;
        width: 100%;
        max-width: 100vw;
    }

    body.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }

    /* Topbar stacks */
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.65rem;
    }

    .topbar h1 {
        font-size: 1.25rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.7rem;
    }

    .stat-card {
        padding: 0.95rem;
    }

    .stat-card .value {
        font-size: 1.35rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: 0.85rem 1rem;
    }

    table th,
    table td {
        padding: 0.55rem 0.5rem;
        font-size: 0.82rem;
    }

    .btn {
        padding: 0.5rem 0.9rem;
        font-size: 0.85rem;
    }

    .btn-sm {
        padding: 0.3rem 0.5rem;
        font-size: 0.74rem;
    }

    .site-grid {
        grid-template-columns: 1fr;
    }

    .methods-grid {
        grid-template-columns: 1fr;
    }

    .method-info {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .method-info dt { margin-top: 0.3rem; }
    .method-info dt:first-child { margin-top: 0; }

    .method-edit .row-2 {
        grid-template-columns: 1fr;
    }

    .method-create-form {
        grid-template-columns: 1fr;
    }

    .api-toolbar {
        flex-direction: column;
        align-items: stretch !important;
    }

    .api-toolbar input,
    .api-toolbar select,
    .api-toolbar .btn,
    .api-toolbar button {
        width: 100%;
    }

    .login-box {
        padding: 1.75rem 1.25rem;
    }

    .modal-content {
        max-height: 85vh;
    }
}

/* ============================================================
   RESPONSIVE — SMALL PHONE ≤ 480px
   ============================================================ */
@media (max-width: 480px) {
    .main-content {
        padding: 0.7rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .topbar h1 {
        font-size: 1.1rem;
    }

    .stat-card .value {
        font-size: 1.25rem;
    }

    .card {
        border-radius: 10px;
        margin-bottom: 1rem;
    }

    .sidebar {
        width: min(300px, 90vw);
    }

    .code-box {
        font-size: 0.75rem;
        padding-right: 4rem;
    }

    table {
        min-width: 480px;
    }
}

/* ============================================================
   LARGE DESKTOP ≥ 1200px
   ============================================================ */
@media (min-width: 1200px) {
    .main-content {
        padding: 1.75rem 2.5rem;
    }

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

/* Prevent horizontal scroll on all screens */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}
