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

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --accent: #e94560;
  --accent-green: #2e8b57;
  --accent-blue: #4169e1;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Auth Screen */
#auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

#auth-screen h1 {
  font-size: 3em;
  margin-bottom: 10px;
}

#auth-screen p {
  color: var(--text-secondary);
  margin-bottom: 40px;
  font-size: 1.2em;
}

#google-signin-btn {
  background: white;
  color: #333;
  border: none;
  padding: 14px 40px;
  font-size: 18px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  transition: transform 0.2s, box-shadow 0.2s;
}

#google-signin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255,255,255,0.2);
}

#auth-error {
  color: var(--accent);
  margin-top: 20px;
  display: none;
}

/* App Shell */
#app {
  display: none;
}

#app.active {
  display: block;
}

/* Header */
header {
  background: var(--bg-secondary);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 1.4em;
}

#user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#user-info img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

#logout-btn {
  background: none;
  border: 1px solid var(--text-secondary);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

/* Status Bar */
#status-bar {
  background: var(--bg-secondary);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
}

.status-dot.online {
  background: #4caf50;
  animation: pulse 2s infinite;
}

.status-dot.offline {
  background: var(--accent);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#status-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Navigation */
nav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  padding: 20px;
}

.nav-item {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius);
  padding: 20px 10px;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  transition: transform 0.2s, background 0.2s;
}

.nav-item:hover {
  transform: translateY(-3px);
  background: var(--accent-blue);
}

.nav-item .icon {
  font-size: 28px;
}

/* Pages */
.page {
  display: none;
  padding: 20px;
  animation: fadeIn 0.3s;
}

.page.active {
  display: block;
}

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

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
}

.page-header h2 {
  font-size: 1.5em;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-bottom: 12px;
  font-size: 1.1em;
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 16px;
  direction: rtl;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 500;
  transition: transform 0.2s, opacity 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

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

.btn-success {
  background: var(--accent-green);
  color: white;
}

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

.btn-block {
  width: 100%;
}

/* Lists */
.item-list {
  list-style: none;
}

.item-list li {
  background: var(--bg-secondary);
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.item-list li .item-actions {
  display: flex;
  gap: 8px;
}

.item-list li .item-actions button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

.item-list li .item-actions button:hover {
  color: var(--accent);
}

/* Sliders */
input[type="range"] {
  width: 100%;
  accent-color: var(--accent-blue);
}

/* Map */
#map-container {
  width: 100%;
  height: 300px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

/* Battery */
.battery-display {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.battery-icon {
  width: 80px;
  height: 40px;
  border: 3px solid var(--text-primary);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.battery-icon::after {
  content: '';
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 16px;
  background: var(--text-primary);
  border-radius: 0 3px 3px 0;
}

.battery-level {
  height: 100%;
  transition: width 0.5s;
}

.battery-info {
  font-size: 2em;
  font-weight: bold;
}

/* Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.toggle {
  width: 50px;
  height: 26px;
  background: #444;
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle.active {
  background: var(--accent-green);
}

.toggle::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  top: 2px;
  right: 2px;
  transition: transform 0.3s;
}

.toggle.active::after {
  transform: translateX(-24px);
}

/* Activity Log */
.log-entry {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  justify-content: space-between;
}

.log-entry .log-time {
  color: var(--text-secondary);
  font-size: 13px;
}

/* Responsive */
@media (max-width: 400px) {
  nav {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
  }
  .nav-item {
    padding: 14px 6px;
    font-size: 11px;
  }
}
