/* نظام الولاء - دار الأميرات - تصميم احترافي + وضع داكن */
:root {
    --primary: #7c3aed;
    --primary-dark: #6d28d9;
    --primary-light: #a78bfa;
    --primary-soft: #f5f3ff;
    --success: #059669;
    --success-soft: #ecfdf5;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --input-bg: #fff;
}

html.dark, body.dark {
    --primary: #a78bfa;
    --primary-dark: #8b5cf6;
    --primary-soft: #1e1b4b;
    --success: #34d399;
    --success-soft: #064e3b;
    --danger: #f87171;
    --danger-soft: #7f1d1d;
    --warning: #fbbf24;
    --warning-soft: #78350f;
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --input-bg: #0f172a;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

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

body {
    font-family: 'Segoe UI', Tahoma, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

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

.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(145deg, #7c3aed 0%, #4c1d95 55%, #2e1065 100%);
    padding: 20px;
}
.login-container { width: 100%; max-width: 400px; }
.login-card {
    background: var(--card); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 40px 32px;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-header h1 { font-size: 22px; color: var(--primary); margin-bottom: 4px; font-weight: 700; }
.login-header p { color: var(--text-muted); font-size: 13px; }
.login-footer { text-align: center; margin-top: 24px; color: var(--text-muted); font-size: 12px; }

.app-header {
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: 12px 20px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow); flex-wrap: wrap; gap: 8px;
}
.app-header .brand { font-weight: 700; font-size: 16px; color: var(--primary); }
.app-header .user-info { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.app-header .role {
    background: var(--primary); color: #fff; padding: 3px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 600;
}

.main-content { max-width: 1000px; margin: 0 auto; padding: 20px 16px 40px; }

.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 22px; margin-bottom: 16px; border: 1px solid var(--border);
}
.card-title {
    font-size: 15px; font-weight: 700; margin-bottom: 14px; color: var(--text);
    display: flex; align-items: center; gap: 8px;
}

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; }
.form-control {
    width: 100%; padding: 14px 16px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); font-size: 16px; background: var(--input-bg); color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
}
.form-control:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s; text-decoration: none; line-height: 1.3;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.95); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
    background: transparent; border: 1.5px solid var(--border); color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-whatsapp:hover { background: #1da851; color: #fff; }

.alert {
    padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; font-weight: 500;
}
.alert-danger { background: var(--danger-soft); color: #991b1b; border: 1px solid #fecaca; }
html.dark .alert-danger { color: #fecaca; }
.alert-success { background: var(--success-soft); color: #065f46; border: 1px solid #a7f3d0; }
html.dark .alert-success { color: #a7f3d0; }
.alert-warning { background: var(--warning-soft); color: #92400e; border: 1px solid #fde68a; }
html.dark .alert-warning { color: #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--border); }
table th { background: var(--bg); font-weight: 700; color: var(--text-muted); font-size: 12px; }
table tr:hover td { background: var(--bg); }

.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px;
}
.stat-card {
    background: var(--card); border-radius: var(--radius); padding: 18px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
}
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat-card .value { font-size: 22px; font-weight: 700; }
.stat-card .value.points { color: var(--primary); }

.search-box { display: flex; gap: 8px; margin-bottom: 14px; position: relative; }
.search-box .form-control { flex: 1; }
.search-wrap { position: relative; flex: 1; }
.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    background: var(--card);
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 280px;
    overflow-y: auto;
    display: none;
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--primary-soft); }
.autocomplete-item .pts {
    color: var(--primary);
    font-weight: 700;
    float: left;
    direction: ltr;
}

.customer-result {
    background: var(--success-soft); border: 1.5px solid #86efac;
    border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
html.dark .customer-result { border-color: #065f46; }
.customer-result h3 { margin-bottom: 2px; color: var(--success); font-size: 17px; }
.customer-result .points-badge {
    display: inline-block; background: var(--primary); color: #fff;
    padding: 5px 14px; border-radius: 20px; font-weight: 700; font-size: 15px; margin-top: 8px;
}

.pin-box {
    background: var(--primary-soft); border: 2px dashed var(--primary-light);
    border-radius: var(--radius); padding: 24px 20px; text-align: center;
}
.pin-box .pin-code {
    font-size: 34px; font-weight: 700; letter-spacing: 10px; color: var(--primary);
    margin: 12px 0 8px; font-family: monospace; direction: ltr;
}

.badge {
    display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-warning { background: #fef3c7; color: #92400e; }
html.dark .badge-success { background: #064e3b; color: #a7f3d0; }
html.dark .badge-danger { background: #7f1d1d; color: #fecaca; }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }
.d-flex { display: flex; } .gap-2 { gap: 10px; }
.justify-between { justify-content: space-between; } .align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.empty-state { text-align: center; padding: 32px 16px; color: var(--text-muted); font-size: 14px; }

.tabs { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: var(--card);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.15s;
}
.tab-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none !important;
}
.tab-btn.active {
    background: var(--primary);
    color: #fff !important;
    border-color: var(--primary);
}

.history-list { list-style: none; }
.history-list li {
    padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px;
    display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.history-list li:last-child { border-bottom: none; }

.customer-page { max-width: 440px; margin: 0 auto; padding: 28px 16px; }
.logo-area { text-align: center; margin-bottom: 24px; }
.logo-area h1 { color: var(--primary); font-size: 24px; font-weight: 700; }
.logo-area p { color: var(--text-muted); font-size: 13px; }
.points-display {
    background: linear-gradient(145deg, #7c3aed 0%, #5b21b6 100%); color: #fff;
    border-radius: 18px; padding: 28px 20px; text-align: center; margin-bottom: 18px;
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.3);
}
.points-display .label { font-size: 13px; opacity: 0.9; margin-bottom: 6px; }
.points-display .number { font-size: 46px; font-weight: 700; line-height: 1.1; }
.points-display .name { margin-top: 10px; font-size: 15px; opacity: 0.95; }

@media print {
    .app-header, .btn, .search-box, .no-print { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card .value { font-size: 18px; }
    .pin-box .pin-code { font-size: 26px; letter-spacing: 6px; }
}


/* ========== Success Banner ========== */
.success-banner {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  animation: fadeIn 0.25s ease;
  padding: 20px;
}
.success-banner.hide {
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.success-banner-inner {
  background: linear-gradient(145deg, #059669 0%, #047857 100%);
  color: #fff;
  border-radius: 20px;
  padding: 36px 40px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(5, 150, 105, 0.4);
  max-width: 360px;
  width: 100%;
  animation: popIn 0.3s ease;
}
.success-banner-label {
  font-size: 15px;
  opacity: 0.95;
  margin-bottom: 8px;
  font-weight: 600;
}
.success-banner-points {
  font-size: 52px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.success-banner-sub {
  font-size: 14px;
  opacity: 0.9;
  margin-top: 4px;
}
.success-banner-name {
  margin-top: 14px;
  font-size: 16px;
  font-weight: 600;
  opacity: 0.95;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
