/* Variables */
:root {
  --primary: #0d6e4e;
  --primary-light: #10a37f;
  --primary-dark: #095c40;
  --gold: #d4af37;
  --gold-light: #e8c547;

  --bg-body: #f5f5f5;
  --bg-card: #ffffff;
  --bg-header: #0d6e4e;

  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-inverse: #ffffff;
  --text-muted: #999999;

  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);

  --radius: 12px;
  --radius-sm: 8px;

  --font-arabic: 'Amiri', serif;
  --font-size-base: 18px;
  --font-size-lg: 22px;
  --font-size-xl: 28px;
  --font-size-dhikr: 24px;
}

/* Dark Mode */
[data-theme="dark"] {
  --bg-body: #121212;
  --bg-card: #1e1e1e;
  --bg-header: #1a3a2e;

  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-muted: #707070;

  --border: #333333;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
}

body {
  font-family: var(--font-arabic);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.8;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.header h1 {
  font-size: 1.3rem;
  font-weight: 700;
}

.icon-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.1);
}

.hidden {
  display: none !important;
}

/* Main Content */
main {
  flex: 1;
  padding-bottom: 70px;
}

.view {
  padding: 16px;
}

/* Quick Access */
.quick-access {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.quick-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.quick-btn:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.quick-btn:active {
  transform: translateY(0);
}

.quick-icon {
  font-size: 2rem;
}

.quick-btn span:last-child {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Search */
.search-box {
  margin-bottom: 20px;
}

.search-box input {
  width: 100%;
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

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

.search-box input::placeholder {
  color: var(--text-muted);
}

/* Chapters Section */
.chapters-section h2 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-right: 4px;
}

.chapters-list {
  list-style: none;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chapter-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.2s;
}

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

.chapter-item:hover {
  background: rgba(13, 110, 78, 0.05);
}

.chapter-item:active {
  background: rgba(13, 110, 78, 0.1);
}

.chapter-num {
  background: var(--primary);
  color: var(--text-inverse);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.chapter-title {
  flex: 1;
  font-size: 1rem;
}

.chapter-arrow {
  color: var(--text-muted);
}

/* Chapter View */
.chapter-header {
  text-align: center;
  margin-bottom: 20px;
}

.chapter-header h2 {
  font-size: 1.3rem;
  color: var(--primary);
}

.athkar-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.athkar-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s;
}

.athkar-item:hover {
  transform: translateY(-2px);
}

.athkar-item:active {
  transform: translateY(0);
}

.athkar-text {
  font-size: var(--font-size-dhikr);
  line-height: 2;
  margin-bottom: 12px;
}

.athkar-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.athkar-count {
  background: var(--gold);
  color: #000;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: bold;
}

/* Dhikr View */
.dhikr-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.dhikr-text {
  font-size: var(--font-size-xl);
  line-height: 2.2;
  margin-bottom: 16px;
  text-align: justify;
}

.dhikr-meta {
  margin-bottom: 24px;
}

.dhikr-source {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Counter */
.counter-section {
  margin: 30px 0;
}

.counter-display {
  font-size: 4rem;
  font-weight: bold;
  color: var(--primary);
  margin-bottom: 8px;
}

.counter-target {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.counter-btn {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--text-inverse);
  border: none;
  font-family: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(13, 110, 78, 0.3);
  transition: transform 0.1s, box-shadow 0.1s;
}

.counter-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 25px rgba(13, 110, 78, 0.4);
}

.counter-btn:active {
  transform: scale(0.98);
}

.counter-btn.completed {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: #000;
}

/* Dhikr Navigation */
.dhikr-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.nav-btn {
  background: var(--bg-body);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#dhikr-progress {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  z-index: 100;
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item:hover {
  color: var(--primary);
}

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

.view:not(.hidden) {
  animation: fadeIn 0.3s ease;
}

/* Responsive */
@media (max-width: 400px) {
  :root {
    --font-size-base: 16px;
    --font-size-dhikr: 20px;
    --font-size-xl: 24px;
  }

  .quick-access {
    grid-template-columns: repeat(2, 1fr);
  }

  .counter-btn {
    width: 140px;
    height: 140px;
  }
}

/* Safe area for notch devices */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: calc(16px + env(safe-area-inset-top));
  }

  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
