/* ============================================================
   MORESON ORDER PORTAL - MOBILE STYLES
   ============================================================ */

:root {
  --primary: #1a5f2a;
  --primary-dark: #144a22;
  --primary-light: #2d8a42;
  --accent: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;
  --blue: #3b82f6;
  --gray: #6b7280;
  --gray-light: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- HIDDEN / VISIBLE ---- */
.hidden { display: none !important; }

/* ---- SCREENS ---- */
.screen { display: none; padding: 80px 16px 100px; min-height: 100vh; }
.screen.active { display: block; }

/* ---- TOP BAR ---- */
#top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 12px;
  background: var(--primary); color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
#top-bar h2 { font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
#top-bar button {
  background: none; border: none; color: white; cursor: pointer;
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: background 0.2s;
}
#top-bar button:active { background: rgba(255,255,255,0.15); }

/* ---- BOTTOM NAV ---- */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; background: white;
  border-top: 1px solid var(--gray-light);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; padding: 8px 4px;
  background: none; border: none; cursor: pointer;
  color: var(--gray); font-size: 11px; transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn.active { color: var(--primary); }
.nav-btn span { font-weight: 500; }

/* ---- LOGIN ---- */
.login-container {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; padding: 32px;
}
.login-logo { width: 120px; height: 120px; margin-bottom: 12px; border-radius: 24px; object-fit: contain; }
.login-container h1 {
  font-size: 28px; font-weight: 700; color: var(--primary);
  letter-spacing: 3px; margin-bottom: 4px;
}
.login-subtitle { color: var(--text-secondary); margin-bottom: 32px; }
.login-form {
  width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px;
}
.login-form label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.login-form input {
  width: 100%; padding: 14px 16px; font-size: 20px; text-align: center;
  border: 2px solid var(--gray-light); border-radius: var(--radius);
  outline: none; letter-spacing: 8px; transition: border 0.2s;
}
.login-form input:focus { border-color: var(--primary); }
.error-text { color: var(--danger); font-size: 13px; text-align: center; }

/* ---- BUTTONS ---- */
.btn-primary {
  width: 100%; padding: 14px; font-size: 16px; font-weight: 600;
  background: var(--primary); color: white; border: none;
  border-radius: var(--radius); cursor: pointer; transition: background 0.2s;
}
.btn-primary:active { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--gray); cursor: not-allowed; }
.btn-small {
  padding: 6px 14px; font-size: 13px; font-weight: 600;
  background: white; color: var(--primary); border: 2px solid var(--primary);
  border-radius: 8px; cursor: pointer;
}
.link-btn {
  background: none; border: none; color: var(--primary);
  font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ---- CARDS ---- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }

/* ---- WELCOME CARD ---- */
.welcome-card { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; }
.welcome-card h3 { font-size: 20px; }
.last-sync { font-size: 12px; opacity: 0.8; margin-top: 4px; }

/* ---- ALERT CARD ---- */
.alert-card {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 2px solid var(--accent); padding: 12px 16px;
}
.alert-icon { font-size: 32px; }
.alert-content { flex: 1; }
.alert-content strong { color: #92400e; font-size: 14px; }
.alert-content p { font-size: 12px; color: #a16207; margin-top: 2px; }

/* ---- KPI GRID ---- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  text-align: center; box-shadow: var(--shadow); cursor: pointer;
  position: relative; transition: transform 0.15s;
}
.kpi-card:active { transform: scale(0.97); }
.kpi-number { font-size: 32px; font-weight: 700; color: var(--primary); }
.kpi-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.kpi-dot {
  width: 10px; height: 10px; border-radius: 50%;
  position: absolute; top: 12px; right: 12px;
}
.dot-blue { background: var(--blue); }
.dot-yellow { background: var(--accent); }
.dot-green { background: var(--success); }
.dot-gray { background: var(--gray); }

/* ---- ACTION GRID ---- */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px; background: var(--bg); border: none;
  border-radius: var(--radius); cursor: pointer; transition: background 0.2s;
}
.action-btn:active { background: var(--gray-light); }
.action-icon { font-size: 24px; }
.action-btn span:last-child { font-size: 12px; font-weight: 600; }

/* ---- SEARCH BAR ---- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.search-bar input {
  flex: 1; border: none; outline: none; font-size: 15px;
  background: transparent;
}
.search-bar svg { color: var(--gray); flex-shrink: 0; }

/* ---- FILTER TABS ---- */
.filter-tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.filter-tab {
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--gray-light); border-radius: 20px;
  background: white; cursor: pointer; white-space: nowrap;
  transition: all 0.2s;
}
.filter-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ---- ORDER LIST ---- */
.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-list-full { display: flex; flex-direction: column; gap: 10px; }
.order-item {
  background: var(--bg); border-radius: var(--radius); padding: 14px;
  cursor: pointer; transition: background 0.15s;
  border-left: 4px solid var(--gray-light);
}
.order-item:active { background: var(--gray-light); }
.order-item.status-open { border-left-color: var(--blue); }
.order-item.status-processing { border-left-color: var(--accent); }
.order-item.status-ready { border-left-color: var(--success); }
.order-item.status-complete { border-left-color: var(--gray); }
.order-item.status-partial { border-left-color: #f97316; }
.order-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.order-ref { font-size: 15px; font-weight: 700; }
.order-month { font-size: 12px; color: var(--text-secondary); }
.order-middle { display: flex; gap: 12px; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.order-bottom { display: flex; justify-content: space-between; align-items: center; }
.order-status {
  display: inline-block; padding: 3px 10px; font-size: 11px; font-weight: 700;
  border-radius: 12px; text-transform: uppercase;
}
.status-badge-open { background: #dbeafe; color: #1e40af; }
.status-badge-processing { background: #fef3c7; color: #92400e; }
.status-badge-ready { background: #d1fae5; color: #065f46; }
.status-badge-complete { background: #e5e7eb; color: #374151; }
.status-badge-partial { background: #ffedd5; color: #9a3412; }
.status-badge-no-order { background: #f3f4f6; color: #9ca3af; }
.order-value { font-size: 14px; font-weight: 600; }
.empty-text { color: var(--text-secondary); font-size: 14px; text-align: center; padding: 24px 0; }

/* ---- ORDER DETAIL ---- */
.detail-header { margin-bottom: 16px; }
.detail-header h2 { font-size: 22px; font-weight: 700; }
.detail-header .detail-month { font-size: 14px; color: var(--text-secondary); }

/* Progress Tracker */
.progress-tracker { display: flex; justify-content: space-between; margin: 20px 0; position: relative; }
.progress-tracker::before {
  content: ''; position: absolute; top: 18px; left: 24px; right: 24px;
  height: 4px; background: var(--gray-light); z-index: 0;
}
.progress-step {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 1; flex: 1;
}
.progress-dot {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gray-light); display: flex;
  align-items: center; justify-content: center; font-size: 16px;
  transition: all 0.3s;
}
.progress-dot.active { background: var(--primary); color: white; box-shadow: 0 0 0 4px rgba(26,95,42,0.2); }
.progress-dot.done { background: var(--success); color: white; }
.progress-label { font-size: 10px; font-weight: 600; text-align: center; color: var(--text-secondary); max-width: 70px; }

/* Detail Sections */
.detail-section { margin-bottom: 16px; }
.detail-section h4 { font-size: 14px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--gray-light); }
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 14px; color: var(--text-secondary); }
.detail-value { font-size: 14px; font-weight: 600; text-align: right; max-width: 60%; }

/* Product Table */
.product-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.product-table th {
  text-align: left; padding: 10px 8px; font-size: 11px; font-weight: 700;
  color: white; background: var(--primary); text-transform: uppercase;
}
.product-table th:first-child { border-radius: 8px 0 0 0; }
.product-table th:last-child { border-radius: 0 8px 0 0; text-align: right; }
.product-table td { padding: 10px 8px; font-size: 13px; border-bottom: 1px solid var(--gray-light); }
.product-table td:last-child { text-align: right; font-weight: 600; }
.product-table tr:last-child td { border-bottom: none; }

/* Detail Actions */
.detail-actions { display: flex; gap: 10px; margin-top: 16px; }
.detail-actions button {
  flex: 1; padding: 12px; font-size: 14px; font-weight: 600;
  border-radius: var(--radius); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-whatsapp { background: #25d366; color: white; }
.btn-change { background: var(--bg); color: var(--text); border: 1px solid var(--gray-light) !important; }
.btn-directions { background: var(--blue); color: white; }

/* ---- QR CODE ---- */
.qr-card { text-align: center; }
.qr-container { margin: 16px auto; }
.qr-container canvas { margin: 0 auto; border: 8px solid white; border-radius: 12px; box-shadow: var(--shadow); }
.qr-label { margin-top: 8px; font-size: 18px; font-weight: 700; color: var(--primary); letter-spacing: 1px; }
.qr-card select { width: 100%; padding: 10px; margin-top: 12px; border: 1px solid var(--gray-light); border-radius: 8px; font-size: 14px; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.form-control {
  width: 100%; padding: 12px 14px; font-size: 15px;
  border: 1px solid var(--gray-light); border-radius: 8px;
  outline: none; background: white; transition: border 0.2s;
}
.form-control:focus { border-color: var(--primary); }
textarea.form-control { resize: vertical; font-family: inherit; }
.success-text { color: var(--success); font-size: 13px; text-align: center; margin-top: 8px; }

/* ---- INFO ITEMS ---- */
.info-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-light); }
.info-item:last-child { border-bottom: none; }
.info-icon { font-size: 24px; flex-shrink: 0; }
.info-item strong { font-size: 14px; display: block; margin-bottom: 2px; }
.info-item p { font-size: 13px; color: var(--text-secondary); }
.info-item .link-btn { margin-top: 4px; display: inline-block; padding: 0; }

/* ---- SUPPORT ---- */
.support-options { display: flex; gap: 12px; }
.support-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px; border: none; border-radius: var(--radius);
  cursor: pointer; font-size: 14px; font-weight: 600; color: white;
  transition: transform 0.15s;
}
.support-btn:active { transform: scale(0.97); }
.support-btn span:first-child { font-size: 32px; }
.whatsapp-btn { background: #25d366; }
.phone-btn { background: var(--blue); }

/* ---- TOAST ---- */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: white; padding: 12px 24px;
  border-radius: 24px; font-size: 14px; font-weight: 500;
  z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- LOADING ---- */
.loading-spinner {
  display: flex; align-items: center; justify-content: center; padding: 40px;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--gray-light);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- OFFLINE BANNER ---- */
.offline-banner {
  background: #fee2e2; color: #991b1b; text-align: center;
  padding: 8px; font-size: 13px; font-weight: 600;
}

/* ---- RESPONSIVE ---- */
@media (min-width: 480px) {
  .screen { padding-left: 24px; padding-right: 24px; }
  .kpi-grid { gap: 14px; }
}
