.admin-container {
    max-width: 1100px;
    width: calc(100% - 160px);
    margin: 48px auto;
    background: rgba(30, 30, 30, 0.85);
    padding: 28px;
    border-radius: 14px;
    color: #fff;
    backdrop-filter: blur(6px);
    box-shadow: 0 8px 40px rgba(0,0,0,0.45);
    box-sizing: border-box;
}

.admin-container h2 {
    margin-bottom: 20px;
    font-size: 28px;
    font-weight: 600;
    text-align: center;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.admin-table th, .admin-table td {
    padding: 12px 15px;
    text-align: left;
}

.admin-table th {
    background: rgba(255,255,255,0.1);
    font-weight: 600;
}

.admin-table tr {
    transition: background 0.2s;
}

.admin-table tr:hover {
    background: rgba(255,255,255,0.05);
}

/* Order items row (hidden by default; toggled via .open) */
.order-items-row { display: none; }
.order-items-row.open { display: table-row; }

/* Order item card inside expanded row */
.order-item-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: #0f1720;
  color: #fff;
  min-width: 260px;
  box-sizing: border-box;
}


.admin-btn {
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: rgb(132, 143, 148);
    font-size: 14px;
    transition: 0.2s;
}

/* Show-details button: improve tap area & ensure it's clickable on mobile */
.show-details-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  z-index: 2;
  min-width: 64px; /* accessible tap target */
}
@media (max-width:480px) {
  .show-details-btn { padding: 10px 12px; font-size:15px; }
}

.btn-ban {
    background: #d9534f;
}

.btn-ban:hover {
    background: #c9302c;
}

.btn-unban {
    background: #5cb85c;
}

.btn-unban:hover {
    background: #449d44;
}

.btn-admin {
    background: #0275d8;
}

.btn-admin:hover {
    background: #025aa5;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 40px;
}

.chart-box {
    background: rgba(255,255,255,0.05);
    padding: 20px;
    border-radius: 12px;
    backdrop-filter: blur(6px);
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
}

.chart-box h3 {
    margin-bottom: 15px;
    text-align: center;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 40px;
}

.chart-box {
    background: rgba(255,255,255,0.05);
    padding: 20px;
    border-radius: 12px;
    backdrop-filter: blur(6px);
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
}

.log-box {
    background: rgba(255,255,255,0.05);
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
}

.log-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.log-item:last-child {
    border-bottom: none;
}

.log-date {
    float: right;
    opacity: 0.6;
}

/* Gallery drag & drop styles */
.gallery-container { gap: 8px; }
.gallery-item { cursor: grab; user-select: none; transition: transform .12s ease, opacity .12s ease; touch-action: none; }
.gallery-item.dragging { opacity: 0.5; transform: scale(.98); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.gallery-item img { display: block; }
#reorderStatus { font-style: italic; opacity: 0.9; }


.admin-input {
    width: 100%;
    padding: 10px 12px;
    margin: 8px 0 15px 0;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #fff;
    transition: background 0.2s, box-shadow 0.2s;
}

/* ensure dropdown lists remain dark */
.admin-input option {
    background: #2a2a2a;
    color: #fff;
}

/* on some browsers the select itself may need a darker bg when focused */
.admin-input:focus { background: rgba(255,255,255,0.2); }

/* modern form layout helpers */
.admin-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px 32px;
}
.admin-form .form-group {
    display: flex;
    flex-direction: column;
}
.admin-form .form-group label {
    margin-bottom: 6px;
    font-weight: 500;
}
/* single column on small screens */
@media(max-width:768px) {
    .admin-form { grid-template-columns: 1fr; }
}

.file-upload-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.gallery-preview { display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
.gallery-preview img { width:80px; height:auto; border-radius:6px; display:block; }

/* message bubble for uploads */
.upload-msg{
    margin-left:8px;
    font-size:13px;
    display:inline-block;
    opacity:0;
    transition:opacity .18s ease;
    color:var(--muted,#6b6b6b);
}
.upload-msg.show{opacity:1}
.upload-msg.success{color:#16a34a}
.upload-msg.error{color:#ff4949}

.admin-input:focus {
    outline: 2px solid #4caf50;
}

.admin-btn-menu {
    display: inline-block;
    padding: 10px 18px;
    margin-right: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    transition: 0.2s;
}

.admin-btn-menu:hover {
    background: rgba(255,255,255,0.2);
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 10px;
    box-sizing: border-box; /* ensure padding doesn't increase width */
    max-width: 100%;
    overflow: hidden; /* prevent children from forcing page overflow */
}

/* Orders page specific filter (responsive) */
.orders-filter { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-top:12px; min-width:0; box-sizing:border-box; }
.orders-filter input[type="date"] { width:160px; max-width:40%; min-width:120px; }
.orders-filter .admin-btn { white-space:nowrap; }
.orders-filter .export-btn { margin-left:4px; }

@media (max-width: 700px) {
  .orders-filter { gap:10px; }
  .orders-filter input[type="date"] { width:48%; max-width:48%; }
  .orders-filter .admin-btn, .orders-filter .export-btn { width:auto; }
}

@media (max-width: 480px) {
  .orders-filter { flex-direction:column; align-items:stretch; gap:8px; padding:10px; min-width:0; }
  .orders-filter label { display:block; width:100%; color:#9aa; font-size:13px; white-space:normal; }
  .orders-filter input[type="date"], .orders-filter .admin-btn, .orders-filter .export-btn { width:100% !important; min-width:0 !important; box-sizing:border-box; white-space:normal; }
  .orders-filter .export-btn { text-align:center; overflow-wrap: anywhere; }
  .filter-form { width: 100%; max-width:100%; padding-left:10px; padding-right:10px; box-sizing:border-box; overflow:hidden; }
  .filter-form .admin-btn, .filter-form .export-btn { word-break: break-word; }

  /* improve mobile table interaction: prevent label from covering controls and enlarge tap area */
  .admin-table td { position: relative; }
  .admin-table td::before { flex: 0 0 auto; max-width: 38%; }
  .orders-table .show-details-btn { z-index: 4; pointer-events: auto; }
}

/* KPI cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.kpi-card {
    background: rgba(255,255,255,0.03);
    padding: 14px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 6px 18px rgba(0,0,0,0.28);
}
.kpi-title { font-size: 13px; color: #9aa; margin-bottom: 8px; }
.kpi-value { font-size: 20px; font-weight: 700; color: #fff; }

.export-btn { display:inline-block; background: rgba(255,255,255,0.06); padding:6px 10px; border-radius:6px; text-decoration:none; color:#fff; font-size:13px; border:1px solid rgba(255,255,255,0.03); }
.preset { background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04); padding:6px 10px; border-radius:6px; cursor:pointer; color:#dfeff2; }
.preset:hover { transform: translateY(-1px); background: rgba(255,255,255,0.04); }

/* Responsive charts layout */
@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr; /* stack charts vertically */
    gap: 18px;
  }
  .chart-box {
    padding: 14px;
  }
  .chart-box h3 { text-align: left; font-size: 16px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

  /* Log box adjustments for tablet and small desktops */
  .log-box { padding: 14px; }
  .log-box .admin-table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .log-box .admin-table thead, .log-box .admin-table tbody { display: table; width: 100%; }
  .log-box .admin-table th, .log-box .admin-table td { white-space: nowrap; }
  .notification-item { padding: 10px; font-size: 14px; }
}

@media (max-width: 480px) {
  .chart-box { padding: 12px; }
  .chart-box h3 { font-size: 15px; }
  /* Give charts a fixed, phone-friendly height so canvas resizes predictably */
  .chart-box canvas { height: 180px !important; width: 100% !important; }
  .admin-container { margin: 12px 8px; padding: 0px; width: calc(100% - 16px); border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,0.28); }
  .kpi-card { padding: 10px; }

  /* Log box — mobile-friendly */
  .log-box { padding: 10px; max-height: 50vh; overflow-y: auto; }
  .log-box .admin-table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .log-box .admin-table th, .log-box .admin-table td { padding: 8px 10px; font-size: 13px; }
  .notification-item { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
  .notification-item .payload { font-size: 13px; }
  .log-date { float: none; margin-top: 6px; opacity: 0.7; text-align: right; }
  /* make action buttons easier to tap on small screens */
  .admin-btn, .admin-btn-menu { padding: 8px 12px; font-size: 14px; }

  /* Orders table — mobile card layout */
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; box-sizing: border-box; }
  /* card-like rows: add horizontal padding so content isn't flush to edges on phones */
  .admin-table tr { margin-bottom: 12px; background: rgba(255,255,255,0.02); padding: 12px; border-radius: 10px; }
  .admin-table td { padding: 6px 12px; border: none; display:flex; justify-content:space-between; align-items:center; box-sizing: border-box; }
  .admin-table td::before { color: #9aa; font-size: 13px; margin-right: 8px; font-weight: 600; flex-shrink: 0; max-width: 50%; overflow-wrap: anywhere; }
  .admin-table tr td:nth-child(1)::before { content: "#"; }
  .admin-table tr td:nth-child(2)::before { content: "Покупатель"; }
  .admin-table tr td:nth-child(3)::before { content: "Телефон"; }
  .admin-table tr td:nth-child(4)::before { content: "Сумма"; }
  .admin-table tr td:nth-child(5)::before { content: "Статус"; }
  .admin-table tr td:nth-child(6)::before { content: "Создан"; }
  .admin-table tr td:nth-child(7)::before { content: "Действия"; }
  /* hide mobile label for orders table specifically */
  .orders-table tr td:nth-child(7)::before { content: ""; }
  .admin-table td:last-child { display:flex; gap:8px; justify-content:flex-end; }
  .admin-table select { min-width: 120px; }
  .order-items-row { display: none; }
  .order-items-row.open { display: block; }
  .order-items-row td { display:block; padding:8px 0; }
  /* Make inner order items flow nicely on phones */
  .order-item-card { min-width: 0 !important; width: 100% !important; flex-wrap:wrap; }
  .order-item-card img { width:44px; height:auto; }
}



/* Notifications */
.notification-item { transition: background .18s ease; padding: 10px; border-radius: 8px; }
.notification-item .payload { color: #9aa; font-size:13px; margin-top:6px; }
.notification-item.unread { background: linear-gradient(90deg, rgba(255,255,255,0.015), rgba(255,255,255,0.01)); }
.notif-icon { cursor: pointer; color: #9b9b9b; transition: transform .12s; }
.notif-icon:hover { transform: scale(1.06); }

