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

button, input, textarea, select {
  font-family: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

:root {
  --primary: #E9FF00;
  --primary-dark: #c4d600;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --gray: #888;
  --light: #1a1a1a;
  --dark: #ffffff;
  --bg-dark: #000000;
}

body {
  font-family: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--dark);
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
}

.screen {
  display: none !important;
  min-height: 100vh;
  padding: 20px;
}

.screen.active {
  display: flex !important;
  flex-direction: column;
}

/* Setup Screen */
#setup-screen.active {
  justify-content: center;
  align-items: center;
  background: var(--bg-dark);
  color: white;
}

/* Scanner Screen */
#scanner-screen.active {
  background: var(--bg-dark);
}

.logo {
  text-align: center;
  margin-bottom: 40px;
}

.logo-img {
  width: 220px;
  height: auto;
  margin-bottom: 10px;
}

.logo p {
  font-size: 1.4rem;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#setup-form {
  width: 100%;
  max-width: 340px;
  background: #111;
  padding: 30px;
  border-radius: 16px;
  border: 1px solid #333;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #ccc;
}

.form-group input {
  width: 100%;
  padding: 14px;
  border: 1px solid #333;
  border-radius: 10px;
  font-size: 16px;
  transition: border-color 0.3s;
  background: #1a1a1a;
  color: white;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group input::placeholder {
  color: #666;
}

.form-group .hint {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: #666;
}

.btn {
  display: inline-block;
  padding: 14px 28px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #000;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #222;
  color: #fff;
  border: 1px solid #444;
}

.btn-icon {
  background: #222;
  border: 1px solid #444;
  border-radius: 8px;
  color: var(--primary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px 12px;
  font-weight: 600;
}

.error-message {
  color: var(--danger);
  text-align: center;
  margin-top: 15px;
  font-size: 14px;
}

/* Header */
#scanner-screen header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 15px;
  border-bottom: 1px solid #333;
}

#scanner-screen header h2 {
  font-size: 1.1rem;
  color: #fff;
  flex: 1;
  text-align: right;
}

/* Stats Bar */
.stats-bar {
  background: var(--primary);
  color: #000;
  padding: 12px 15px;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 15px;
  font-size: 18px;
  font-weight: 700;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #111;
  padding: 30px;
  border-radius: 16px;
  width: 90%;
  max-width: 350px;
  text-align: center;
  border: 1px solid #333;
}

.modal-content h3 {
  margin-bottom: 20px;
}

/* Scanner Screen */
#scanner-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #111;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid #333;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.scanner-frame {
  width: 70%;
  height: 70%;
  border: 3px solid var(--primary);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.6);
}

#manual-entry {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

#manual-code {
  flex: 1;
  padding: 14px;
  border: 1px solid #333;
  border-radius: 10px;
  font-size: 16px;
  background: #111;
  color: white;
}

#manual-code::placeholder {
  color: #666;
}

.scan-result {
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 15px;
}

.scan-result.success {
  background: #d4edda;
  color: #155724;
}

.scan-result.error {
  background: #f8d7da;
  color: #721c24;
}

.scan-result.warning {
  background: #fff3cd;
  color: #856404;
}

.offline-indicator {
  background: #332200;
  color: #ffcc00;
  padding: 10px;
  border-radius: 10px;
  text-align: center;
  font-size: 14px;
  margin-bottom: 10px;
  border: 1px solid #553300;
}

.pending-count {
  background: #332200;
  color: #ffcc00;
  padding: 10px;
  border-radius: 10px;
  text-align: center;
  font-size: 14px;
  margin-bottom: 10px;
  border: 1px solid #553300;
}

.success-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  border: 2px solid var(--primary);
  border-radius: 16px;
  padding: 20px 30px;
  text-align: center;
  z-index: 1001;
  min-width: 250px;
  animation: popIn 0.3s ease;
  overflow: hidden;
}

@keyframes popIn {
  0% { transform: translateX(-50%) scale(0.8); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

.success-toast .success-icon {
  font-size: 50px;
  color: var(--primary);
  animation: checkPop 0.5s ease;
}

@keyframes checkPop {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.success-toast .success-text {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  margin-top: 10px;
}

.success-toast .success-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: var(--primary);
  animation: shrinkBar 1.5s linear forwards;
}

@keyframes shrinkBar {
  0% { width: 100%; }
  100% { width: 0%; }
}

.search-results {
  background: #111;
  border: 1px solid #333;
  border-radius: 10px;
  margin-bottom: 15px;
  max-height: 200px;
  overflow-y: auto;
}

.search-result-item {
  padding: 12px 15px;
  border-bottom: 1px solid #222;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:active {
  background: #222;
}

.search-result-item .name {
  font-weight: 600;
  color: #fff;
}

.search-result-item .code {
  font-size: 12px;
  color: #888;
}

.search-result-item.checked-in {
  opacity: 0.5;
}

.search-result-item .status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}

.search-result-item .status.available {
  background: var(--primary);
  color: #000;
}

.search-result-item .status.done {
  background: #1a3d1a;
  color: #4ade80;
}

.search-result-item .status.unknown {
  background: #2a2a2a;
  color: #888;
  font-size: 18px;
}

.refresh-btn {
  width: 100%;
  margin-top: 10px;
}

.hidden {
  display: none !important;
}

/* Result Modal */
.result-content {
  padding: 40px 30px;
}

#result-icon {
  font-size: 60px;
  margin-bottom: 20px;
}

#result-title {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

#result-message {
  color: #999;
  margin-bottom: 25px;
}

/* Responsive */
@media (max-width: 400px) {
  .logo h1 {
    font-size: 2.5rem;
  }
  
  #setup-form {
    padding: 20px;
  }
}
