/* ==========================================================================
   التقويم الشامل (Universal Calendar) - Core Design System & Layout
   Premium Dark Charcoal & Refined Gold Visual System
   Responsive Desktop, Tablet & Mobile Architecture
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Cairo:wght@300;400;500;600;700;800&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Color Palette - Deep Charcoal & Obsidian */
  --bg-body: #080a0f;
  --bg-surface: #0e121a;
  --bg-card: rgba(18, 24, 37, 0.85);
  --bg-card-hover: rgba(26, 34, 52, 0.95);
  --bg-card-active: rgba(32, 42, 65, 0.98);
  --bg-input: #121722;
  --bg-glass: rgba(14, 18, 26, 0.88);

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-gold: rgba(212, 175, 55, 0.35);
  --border-gold-glow: rgba(212, 175, 55, 0.65);

  /* Gold & Warm Accents */
  --gold-primary: #d4af37;
  --gold-light: #f5e4a8;
  --gold-dark: #997a15;
  --gold-hover: #e5c158;
  --gold-gradient: linear-gradient(135deg, #e5c158 0%, #d4af37 50%, #997a15 100%);
  --gold-shadow: 0 4px 20px rgba(212, 175, 55, 0.18);

  /* Semantic Colors */
  --color-sun: #f59e0b;
  --color-moon: #38bdf8;
  --color-crescent: #10b981;
  --color-season: #a855f7;
  --color-leap: #e11d48;

  /* Typography & High-Contrast Colors */
  --text-primary: #ffffff;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-gold: #f5e4a8;

  --font-arabic: 'Cairo', system-ui, -apple-system, sans-serif;
  --font-classical: 'Amiri', serif;
  --font-latin: 'Outfit', system-ui, -apple-system, sans-serif;

  /* Geometry & Motion */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background-color: var(--bg-body);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-arabic);
  background-color: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  overflow-x: hidden;
  position: relative;
  background-image: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(212, 175, 55, 0.07), transparent 70%),
    radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.03), transparent 50%);
}

/* LTR override when English is selected */
html[lang="en"] body {
  font-family: var(--font-latin);
}

a {
  color: var(--gold-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--gold-light);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gold-primary);
}

/* App Shell Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* ==========================================================================
   Header & Branding
   ========================================================================== */
.app-header {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1.5rem;
  width: 100%;
  max-width: 100%;
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  cursor: pointer;
  text-decoration: none;
}

.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(212, 175, 55, 0.3));
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Action Buttons */
.btn-action {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-action:hover {
  background: var(--bg-card-hover);
  color: #ffffff;
  border-color: var(--border-gold);
}

.btn-action.active {
  background: var(--bg-card-active);
  color: var(--gold-light);
  border-color: var(--gold-primary);
  box-shadow: var(--gold-shadow);
}

.btn-gold {
  background: var(--gold-gradient);
  color: #080a0f;
  border: none;
  font-weight: 700;
  box-shadow: var(--gold-shadow);
}

.btn-gold:hover {
  background: linear-gradient(135deg, #f5e4a8 0%, #e5c158 100%);
  color: #000;
}

/* ==========================================================================
   Multi-Tab Navigation Bar (av.java / s.java)
   ========================================================================== */
.tabs-navbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.4rem 1.5rem 0;
  width: 100%;
  max-width: 100%;
}

.tabs-inner {
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tabs-strip {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}

.tabs-strip::-webkit-scrollbar {
  display: none;
}

.tab-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  color: var(--text-secondary);
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  position: relative;
}

.tab-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.tab-pill.active {
  background: var(--bg-body);
  color: var(--gold-light);
  border-color: var(--border-gold);
  border-bottom: 1px solid var(--bg-body);
  z-index: 2;
}

.tab-pill.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2.5px;
  background: var(--gold-gradient);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.tab-badge {
  font-size: 0.78rem;
  background: rgba(212, 175, 55, 0.2);
  color: var(--gold-light);
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.tab-close {
  opacity: 0.6;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.tab-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-leap);
}

.btn-new-tab {
  background: none;
  border: 1px dashed var(--border-medium);
  color: var(--text-secondary);
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.btn-new-tab:hover {
  border-color: var(--gold-primary);
  color: var(--gold-primary);
  background: rgba(212, 175, 55, 0.08);
}

/* ==========================================================================
   Main View Stage Container
   ========================================================================== */
.main-stage {
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  box-sizing: border-box;
}

/* ==========================================================================
   Modals & Drawers
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), var(--gold-shadow);
  transform: translateY(15px) scale(0.98);
  transition: transform var(--transition-smooth);
  overflow: hidden;
  margin: 0;
}

.modal-backdrop.open .modal-box {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold-light);
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

/* Form Controls in Modals */
.input-search {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  color: #ffffff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  min-height: 44px;
  transition: border-color var(--transition-fast);
}

.input-search:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

/* ==========================================================================
   Mandatory Footer
   ========================================================================== */
.app-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 1.25rem 1.5rem;
  margin-top: auto;
  width: 100%;
  max-width: 100%;
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.footer-brand {
  font-weight: 600;
  color: var(--gold-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all var(--transition-fast);
}

.footer-brand:hover {
  color: var(--gold-light);
  transform: translateY(-1px);
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (Desktop, Tablet, Mobile)
   ========================================================================== */

@media (max-width: 768px) {
  .app-header {
    padding: 0.65rem 0.85rem;
  }

  .header-inner {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.6rem;
  }

  .brand-section {
    width: 100%;
    justify-content: flex-start;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  .brand-title {
    font-size: 1.2rem;
  }

  .brand-subtitle {
    font-size: 0.78rem;
  }

  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .header-actions #btn-toggle-lang {
    grid-column: span 2;
    order: -1;
  }

  .header-actions .btn-action {
    width: 100%;
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
  }

  .tabs-navbar {
    padding: 0.35rem 0.85rem 0;
  }

  .main-stage {
    padding: 0.85rem 0.85rem;
    width: 100%;
    max-width: 100%;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
    justify-content: center;
    gap: 0.65rem;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  .app-header {
    padding: 0.5rem 0.65rem;
  }

  .main-stage {
    padding: 0.65rem 0.65rem;
  }

  .header-actions {
    grid-template-columns: 1fr;
  }

  .header-actions #btn-toggle-lang {
    grid-column: span 1;
  }

  .modal-backdrop {
    padding: 8px;
  }

  .modal-box {
    max-height: calc(100vh - 16px);
  }
}
