@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary-color: #7c3aed;
  --secondary-color: #06b6d4;
  --accent-color: #f59e0b;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #3b82f6;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-accent: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --gradient-success: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

body.dark {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-light: #475569;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.3);
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-accent: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --gradient-success: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  text-align: center;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.3s ease;
  min-height: 100vh;
  line-height: 1.6;
  background-image: 
    radial-gradient(circle at 20% 80%, rgba(124, 58, 237, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(245, 158, 11, 0.03) 0%, transparent 50%);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

#clock {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 700;
  margin: 1.5rem 0;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#date, #hijri-date {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin: 0.5rem 0;
  font-weight: 500;
}

#greeting {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary-color);
  margin: 1rem 0;
}

section {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

section h3 {
  margin-top: 0;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.2rem;
}

#prayer-times {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

#prayer-times div {
  background: var(--bg-primary);
  padding: 1rem;
  border-radius: 8px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#prayer-times div:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

#prayer-times .current-prayer {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border-color: var(--primary-color);
  font-weight: 600;
  animation: pulse 2s infinite;
}

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

#compass-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#compass {
  width: 200px;
  height: 200px;
  border: 4px solid var(--primary-color);
  border-radius: 50%;
  margin: 1.5rem auto;
  position: relative;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

#compass-rose {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

#compass-rose::before,
#compass-rose::after {
  content: '';
  position: absolute;
  background: var(--text-secondary);
  opacity: 0.3;
}

#compass-rose::before {
  width: 2px;
  height: 100%;
  left: 50%;
  transform: translateX(-50%);
}

#compass-rose::after {
  width: 100%;
  height: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.compass-degree {
  position: absolute;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.compass-degree.n { top: 5px; left: 50%; transform: translateX(-50%); }
.compass-degree.e { right: 5px; top: 50%; transform: translateY(-50%); }
.compass-degree.s { bottom: 5px; left: 50%; transform: translateX(-50%); }
.compass-degree.w { left: 5px; top: 50%; transform: translateY(-50%); }

.compass-degree.ne { top: 15px; right: 15px; }
.compass-degree.se { bottom: 15px; right: 15px; }
.compass-degree.sw { bottom: 15px; left: 15px; }
.compass-degree.nw { top: 15px; left: 15px; }

#needle {
  width: 3px;
  height: 80px;
  background: linear-gradient(to top, var(--accent-color), #ef4444);
  position: absolute;
  bottom: 50%;
  left: 50%;
  transform-origin: bottom center;
  transform: translateX(-50%);
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(220, 38, 38, 0.5);
  transition: transform 0.3s ease-out;
  z-index: 10;
}

#needle::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--accent-color);
  border-radius: 50%;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 5px rgba(220, 38, 38, 0.5);
}

#compass-info {
  text-align: center;
  width: 100%;
}

#compass-info p {
  margin: 0.25rem 0;
}

.compass-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 5;
  background: var(--bg-secondary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

label {
  display: inline-flex;
  align-items: center;
  margin: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

label:hover {
  color: var(--primary-color);
  background: var(--bg-tertiary);
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

input[type="checkbox"] {
  margin-right: 0.75rem;
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
  accent-color: var(--primary-color);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

input[type="checkbox"]:checked {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

select {
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 200px;
  box-shadow: var(--shadow);
}

select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
  transform: translateY(-1px);
}

select:hover {
  border-color: var(--primary-color);
}

#monthly-table {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
}

#monthly-table div {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#monthly-table div:last-child {
  border-bottom: none;
}

#monthly-table div:hover {
  background: var(--bg-secondary);
}

#islamic-content {
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
  border: 1px solid var(--border-color);
}

#verse-of-day {
  color: var(--primary-color);
  font-size: 1.1rem;
  font-weight: 500;
}

#hadith-of-day {
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
  margin-top: 1rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (max-width: 768px) {
  main {
    padding: 0.75rem;
  }
  
  section {
    padding: 1rem;
    margin: 1rem 0;
  }
  
  #compass {
    width: 160px;
    height: 160px;
  }
  
  #needle {
    height: 60px;
  }
  
  #prayer-times {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
  }
  
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  #clock {
    font-size: 2rem;
  }
  
  #greeting {
    font-size: 1.1rem;
  }
  
  label {
    display: block;
    margin: 0.75rem 0;
  }
  
  select {
    width: 100%;
  }
}

body[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

body[dir="rtl"] header {
  direction: ltr;
}

body[dir="rtl"] .settings-grid {
  direction: rtl;
}

body[dir="rtl"] #side-menu {
  left: -350px;
  right: auto;
}

body[dir="rtl"] #side-menu.active {
  left: 0;
  right: auto;
}

body[dir="rtl"] .modal-content {
  direction: rtl;
}

body[dir="rtl"] .settings-tabs {
  direction: ltr;
}

/* ==================== MODAL STYLES ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  animation: slideUp 0.3s ease;
  border: 1px solid var(--border-color);
}

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

.modal-header {
  background: var(--gradient-primary);
  color: white;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.modal-body {
  padding: 2rem;
  max-height: calc(90vh - 120px);
  overflow-y: auto;
}

/* ==================== SETTINGS TABS ==================== */
.settings-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 1rem;
}

.tab-btn {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-1px);
}

.tab-btn.active {
  background: var(--gradient-primary);
  color: white;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

.tab-content {
  display: none;
  animation: fadeInContent 0.3s ease;
}

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

@keyframes fadeInContent {
  from { 
    opacity: 0;
    transform: translateX(-10px);
  }
  to { 
    opacity: 1;
    transform: translateX(0);
  }
}

/* ==================== ENHANCED BUTTONS ==================== */
button {
  background: var(--gradient-primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

button:hover::before {
  left: 100%;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow);
}

/* ==================== VOLUME SLIDER ==================== */
input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
  outline: none;
  margin: 1rem 0;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--border-color);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gradient-primary);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-lg);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gradient-primary);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-lg);
}

#volume-display {
  background: var(--bg-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  color: var(--primary-color);
  border: 1px solid var(--border-color);
  display: inline-block;
  min-width: 60px;
  text-align: center;
}


/* ==================== ZAKAT CALCULATOR ==================== */
.zakat-calculator {
  background: linear-gradient(135deg, var(--success-color), var(--info-color));
  color: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-lg);
}

.zakat-result {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-top: 1rem;
  border: 2px solid var(--success-color);
  box-shadow: var(--shadow-md);
}

/* ==================== LOADING STATES ==================== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s linear infinite;
}

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

/* ==================== NOTIFICATION TOAST ==================== */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--gradient-primary);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 4000;
  animation: slideInRight 0.3s ease;
  max-width: 300px;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ==================== LANGUAGE SELECTOR RESPONSIVE ==================== */
.language-selector-wrapper {
  display: flex;
  align-items: center;
}

#language-select-top {
  transition: all 0.3s ease;
}

#language-select-top:hover {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.1);
}

#language-select-top:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .language-selector-wrapper #language-select-top {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    min-width: 55px;
  }
  
  header > div > div:last-child {
    gap: 0.3rem;
  }
}

@media (max-width: 480px) {
  .language-selector-wrapper #language-select-top {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    min-width: 50px;
  }
  
  header > div > div:last-child {
    gap: 0.25rem;
  }
  
  #menu-toggle {
    padding: 0.6rem;
  }
}

@media (max-width: 360px) {
  .language-selector-wrapper #language-select-top {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    min-width: 45px;
  }
  
  header {
    padding: 0.75rem 1rem;
  }
  
  .header-title {
    font-size: 1.2rem;
  }
  
  .header-title img {
    width: 32px;
    height: 32px;
  }
  
  .main-title {
    font-size: 0.9rem;
  }
  
  .title-content small {
    font-size: 0.6em;
  }
}

/* ==================== HEADER RESPONSIVE FIXES ==================== */
header {
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.dark header {
  background: rgba(15, 23, 42, 0.3);
}

.header-title {
  flex-shrink: 1;
  min-width: 0;
  max-width: calc(100% - 120px);
}

.title-content {
  min-width: 0;
  flex: 1;
}

.main-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.title-content small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Responsive header adjustments */
@media (max-width: 768px) {
  .header-title {
    max-width: calc(100% - 140px);
  }
  
  .main-title {
    font-size: 1.1rem;
  }
  
  .title-content small {
    font-size: 0.65em;
  }
}

@media (max-width: 640px) {
  .header-title {
    max-width: calc(100% - 130px);
  }
  
  .main-title {
    font-size: 1rem;
  }
  
  .title-content small {
    font-size: 0.6em;
  }
}

@media (max-width: 480px) {
  .header-title {
    max-width: calc(100% - 120px);
    gap: 0.5rem;
  }
  
  .header-title img {
    width: 36px;
    height: 36px;
  }
  
  .main-title {
    font-size: 0.95rem;
  }
  
  .title-content small {
    font-size: 0.55em;
  }
}

@media (max-width: 400px) {
  .header-title {
    max-width: calc(100% - 110px);
    gap: 0.4rem;
  }
  
  .header-title img {
    width: 32px;
    height: 32px;
  }
  
  .main-title {
    font-size: 0.9rem;
  }
  
  .title-content small {
    font-size: 0.5em;
  }
}

@media (max-width: 320px) {
  .header-title {
    max-width: calc(100% - 100px);
    gap: 0.3rem;
  }
  
  .header-title img {
    width: 28px;
    height: 28px;
  }
  
  .main-title {
    font-size: 0.85rem;
  }
  
  .title-content small {
    font-size: 0.45em;
  }
  
  header {
    padding: 0.5rem 0.75rem;
  }
}