/* SIM Portal — ALMAS Industries */
/* Mobile-first responsive design */

:root {
  --primary: #003366;
  --primary-light: #0066cc;
  --accent: #0088ff;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* === HEADER === */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header .user-info {
  font-size: 13px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-logout {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-logout:hover { background: rgba(255,255,255,0.25); }

/* === LOGIN === */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #001a33 100%);
}

.login-box {
  background: white;
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-box h1 {
  text-align: center;
  color: var(--primary);
  margin-bottom: 8px;
  font-size: 24px;
}

.login-box .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 14px;
}

.login-box .logo {
  text-align: center;
  font-size: 48px;
  margin-bottom: 16px;
}

/* === FORMS === */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px; /* Prevents zoom on iOS */
  transition: border-color 0.2s;
  outline: none;
  -webkit-appearance: none;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,136,255,0.1);
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-light); }
.btn-primary:active { transform: scale(0.98); }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: var(--text); }

.btn-scan {
  background: linear-gradient(135deg, var(--accent), var(--primary-light));
  color: white;
  padding: 20px;
  font-size: 18px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,102,204,0.3);
}

.btn-scan:active { transform: scale(0.96); }

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  width: auto;
}

/* === TABS === */
.tabs {
  display: flex;
  background: white;
  border-bottom: 2px solid var(--border);
  padding: 0 16px;
}

.tab {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* === MAIN CONTENT === */
.container {
  padding: 16px;
  max-width: 800px;
  margin: 0 auto;
}

/* === SCAN SECTION === */
.scan-section {
  text-align: center;
  margin-bottom: 20px;
}

.scan-section p {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 13px;
}

.manual-input {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.manual-input input {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  outline: none;
}

.manual-input input:focus {
  border-color: var(--accent);
}

.manual-input .btn {
  width: auto;
  padding: 12px 20px;
  white-space: nowrap;
}

/* === SCANNER === */
#scanner-container {
  display: none;
  margin: 16px 0;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: #000;
}

#scanner-container video {
  width: 100%;
  border-radius: 12px;
}

.scanner-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 60px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
}

/* === SIM CARD === */
.sim-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.sim-card h3 {
  font-size: 15px;
  color: var(--primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sim-field {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}

.sim-field:last-child { border-bottom: none; }

.sim-field .label {
  color: var(--text-muted);
  font-weight: 500;
  min-width: 120px;
}

.sim-field .value {
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

/* === STATUS BADGES === */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-ACTIVATED { background: #d4edda; color: #155724; }
.status-DEACTIVATED { background: #f8d7da; color: #721c24; }
.status-TEST_READY { background: #fff3cd; color: #856404; }
.status-INVENTORY { background: #e2e3e5; color: #383d41; }
.status-RETIRED { background: #d6d8db; color: #383d41; }

/* === STATUS CHANGE === */
.status-change-section {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.status-change-section h4 {
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--text);
}

.status-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-actions .btn {
  width: auto;
  flex: 1;
  min-width: 100px;
  padding: 10px 16px;
  font-size: 13px;
}

/* === OLD SIMS TABLE === */
.sim-list {
  margin-top: 16px;
}

.sim-list-item {
  background: white;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: transform 0.1s;
}

.sim-list-item:active { transform: scale(0.99); }

.sim-list-item .iccid {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}

.sim-list-item .meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* === TOAST === */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: slideUp 0.3s ease;
  pointer-events: auto;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === LOADING === */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* === RESPONSIVE === */
@media (min-width: 768px) {
  .header h1 { font-size: 20px; }
  .container { padding: 24px; }
  .sim-card { padding: 24px; }
  .manual-input input { font-size: 15px; }
  .status-actions .btn { flex: none; }
}

/* === UTILITIES === */
.hidden { display: none !important; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
