/* =============================================
   WooAdmin Cloud — Main Stylesheet
   ============================================= */

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

:root {
  --bg:        #f5f4f1;
  --surface:   #ffffff;
  --surface2:  #f9f8f6;
  --border:    rgba(0,0,0,0.09);
  --border2:   rgba(0,0,0,0.16);
  --text:      #1a1a18;
  --text2:     #6b6a66;
  --text3:     #9e9d99;
  --green:     #1D9E75;
  --green-dk:  #0F6E56;
  --green-lt:  #e1f5ee;
  --amber:     #BA7517;
  --amber-lt:  #faeeda;
  --red:       #D85A30;
  --red-lt:    #faece7;
  --blue:      #185FA5;
  --blue-lt:   #e6f1fb;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--border2); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface2); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-dk); border-color: var(--green-dk); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--red-lt); color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #f9ddd6; }
.btn-icon { padding: 6px; border-radius: var(--radius); border: 1px solid var(--border); background: transparent; cursor: pointer; color: var(--text2); display: inline-flex; align-items: center; }
.btn-icon:hover { background: var(--surface2); color: var(--text); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.badge-pending    { background: var(--amber-lt); color: var(--amber); }
.badge-processing { background: var(--blue-lt);  color: var(--blue); }
.badge-completed  { background: var(--green-lt); color: var(--green-dk); }
.badge-refunded   { background: var(--red-lt);   color: var(--red); }
.badge-cancelled  { background: #f1efe8; color: #5f5e5a; }
.badge-draft      { background: #f1efe8; color: #5f5e5a; }
.badge-publish    { background: var(--green-lt); color: var(--green-dk); }
.badge-low        { background: var(--red-lt);   color: var(--red); }

/* ---- Form elements ---- */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], input[type="search"],
select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border2); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,158,117,0.12); }
label { font-size: 12px; color: var(--text2); display: block; margin-bottom: 5px; font-weight: 500; }
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-prefix { display: flex; }
.input-prefix span { padding: 9px 10px; background: var(--surface2); border: 1px solid var(--border2); border-right: none; border-radius: var(--radius) 0 0 var(--radius); color: var(--text2); font-size: 12px; white-space: nowrap; }
.input-prefix input { border-radius: 0 var(--radius) var(--radius) 0; }

/* ---- LOGIN PAGE ---- */
#login-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 24px;
  background: var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 36px 32px;
}
.login-logo { margin-bottom: 28px; }
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--text); }
.login-logo p { font-size: 13px; color: var(--text2); margin-top: 3px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
.login-error { background: var(--red-lt); color: var(--red); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; display: none; }
.login-error.show { display: block; }

/* ---- APP SHELL ---- */
#app { display: none; height: 100vh; flex-direction: column; }
#app.ready { display: flex; }

.app-bar {
  height: 52px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 16px; flex-shrink: 0;
  position: sticky; top: 0; z-index: 100;
}
.app-bar-brand { font-size: 15px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.app-bar-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.app-bar-store { font-size: 12px; color: var(--text2); border-left: 1px solid var(--border); padding-left: 14px; }
.app-bar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.app-bar-right .btn { font-size: 12px; padding: 5px 12px; }

.app-body { display: flex; flex: 1; overflow: hidden; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: 210px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto;
}
.nav-section-label {
  padding: 16px 16px 4px; font-size: 10px; letter-spacing: 0.08em;
  color: var(--text3); text-transform: uppercase; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; font-size: 13px; color: var(--text2);
  cursor: pointer; transition: background .1s, color .1s;
  border-right: 2px solid transparent; user-select: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--text); font-weight: 600; border-right-color: var(--green); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--amber-lt); color: var(--amber); border-radius: 20px; padding: 1px 7px; font-size: 10px; font-weight: 700; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 14px; }
.store-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); }
.store-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }

/* ---- MAIN CONTENT ---- */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

.page { display: none; flex-direction: column; flex: 1; }
.page.active { display: flex; }

.page-header {
  padding: 16px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; gap: 12px; flex-wrap: wrap;
}
.page-header h2 { font-size: 17px; font-weight: 700; color: var(--text); }
.page-header-right { display: flex; align-items: center; gap: 8px; }

.toolbar {
  padding: 12px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap;
}
.toolbar input[type="search"] { width: 240px; }
.toolbar select { width: auto; }

.page-content { padding: 24px; flex: 1; }

/* ---- METRICS ---- */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 24px; }
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
}
.metric-card .icon { width: 32px; height: 32px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.metric-card .label { font-size: 12px; color: var(--text2); margin-bottom: 4px; font-weight: 500; }
.metric-card .value { font-size: 24px; font-weight: 700; color: var(--text); }
.metric-card .trend { font-size: 11px; color: var(--text3); margin-top: 4px; }
.trend-up { color: var(--green) !important; }
.trend-dn { color: var(--red) !important; }

/* ---- TABLE ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px; font-size: 11px; font-weight: 700; color: var(--text2);
  text-align: left; background: var(--surface2); border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }
.td-muted { color: var(--text2) !important; }
.td-mono { font-family: monospace; font-size: 12px; }
.td-bold { font-weight: 600; }
.td-danger { color: var(--red) !important; font-weight: 600; }
.td-warning { color: var(--amber) !important; font-weight: 600; }

/* ---- AVATAR ---- */
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue-lt); color: var(--blue);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}

/* ---- PAGINATION ---- */
.pagination { display: flex; align-items: center; gap: 6px; padding: 16px 24px; justify-content: flex-end; }
.pagination span { font-size: 12px; color: var(--text2); }
.page-info { font-size: 13px; color: var(--text2); }

/* ---- LOADING / EMPTY ---- */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 24px; gap: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border2); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state p { color: var(--text2); font-size: 13px; }
.empty-state { display: flex; flex-direction: column; align-items: center; padding: 60px 24px; gap: 8px; }
.empty-state p { color: var(--text2); font-size: 13px; }

/* ---- TOAST ---- */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff; border-radius: var(--radius);
  padding: 10px 16px; font-size: 13px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18); animation: slideIn .2s ease;
  max-width: 320px;
}
.toast.success { background: var(--green-dk); }
.toast.error   { background: #993C1D; }
@keyframes slideIn { from { transform: translateX(20px); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* ---- MODAL ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---- DASHBOARD GRID ---- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 20px; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.panel-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-header h3 { font-size: 13px; font-weight: 700; color: var(--text); }
.panel-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  font-size: 12px; cursor: pointer;
}
.panel-row:last-child { border-bottom: none; }
.panel-row:hover { background: var(--surface2); }

/* ---- BAR CHART ---- */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 100px; padding: 16px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.bar-col .bar { width: 100%; border-radius: 3px 3px 0 0; background: var(--green-lt); min-height: 4px; transition: background .15s; cursor: pointer; }
.bar-col .bar:hover { background: var(--green); }
.bar-col .lbl { font-size: 10px; color: var(--text3); }

/* ---- STOCK BAR ---- */
.stock-bar-wrap { flex: 1; height: 5px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.stock-bar-fill { height: 100%; border-radius: 4px; }

/* ---- SETTINGS ---- */
.settings-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 20px; }
.settings-panel-title { padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 13px; font-weight: 500; }
.settings-row-hint { font-size: 11px; color: var(--text2); margin-top: 2px; }
.toggle { width: 36px; height: 20px; border-radius: 20px; background: var(--green); position: relative; cursor: pointer; flex-shrink: 0; transition: background .15s; }
.toggle::after { content:''; width:16px; height:16px; border-radius:50%; background:#fff; position:absolute; top:2px; right:2px; transition: right .15s; }
.toggle.off { background: var(--border2); }
.toggle.off::after { right: 18px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar { width: 52px; }
  .nav-item span, .nav-section-label, .sidebar-bottom, .app-bar-store { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .dash-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}
