/* Modern Dashboard Shared Styles */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800;900&display=swap');

* {
      -webkit-tap-highlight-color: transparent;
    }

    /* --- Modern Sidebar Variables --- */
    :root {
      --color-text-primary: #1F2936;
      --color-text-placeholder: #798EAE;
      --color-bg-primary: #f1f5f9;
      --color-bg-secondary: #ECECFD;
      --color-bg-sidebar: #FFFFFF;
      --color-border-hr: #E2E8F0;
      --color-hover-primary: #695CFE;
      --color-hover-secondary: #e2e2fb;
      --color-shadow: rgba(0, 0, 0, 0.05);
    }

    body.dark-theme {
      --color-text-primary: #F1F5F9;
      --color-text-placeholder: #A6B7D2;
      --color-bg-primary: #0f172a;
      --color-bg-secondary: #1e293b;
      --color-bg-sidebar: #1e293b;
      --color-border-hr: #334155;
      --color-hover-primary: #8b5cf6;
      --color-hover-secondary: #334155;
      --color-shadow: rgba(0, 0, 0, 0.3);
    }

    body {
      font-family: 'Tajawal', sans-serif;
      background: var(--color-bg-primary);
      color: var(--color-text-primary);
      overflow-x: hidden;
      transition: background 0.3s, color 0.3s;
    }

    /* Layout Architecture */
    .app-wrapper {
      display: flex;
      height: 100vh;
      overflow: hidden;
      width: 100%;
    }

    /* --- Professional Sidebar Styles (Adapted for RTL) --- */
    .sidebar {
      position: relative;
      width: 270px;
      height: 100vh;
      display: flex;
      flex-shrink: 0;
      flex-direction: column;
      background: var(--color-bg-sidebar);
      border-left: 1px solid var(--color-border-hr);
      box-shadow: -3px 0 9px var(--color-shadow);
      transition: width 0.4s ease, background 0.3s, border 0.3s;
      z-index: 50;
    }

    .sidebar.collapsed {
      width: 90px;
    }

    .sidebar-header {
      padding: 20px 18px;
      display: flex;
      position: relative;
      align-items: center;
      justify-content: space-between;
      border-bottom: 1px solid var(--color-border-hr);
    }

    .header-logo-container {
      display: flex;
      align-items: center;
      gap: 12px;
      transition: opacity 0.4s ease;
      overflow: hidden;
      white-space: nowrap;
    }

    .sidebar.collapsed .header-logo-container {
      opacity: 0;
      pointer-events: none;
    }

    .sidebar-toggle {
      height: 40px;
      width: 40px;
      border: none;
      cursor: pointer;
      display: flex;
      position: absolute;
      left: 18px;
      align-items: center;
      justify-content: center;
      border-radius: 8px;
      color: var(--color-text-primary);
      background: var(--color-bg-secondary);
      transition: 0.4s ease;
    }

    .sidebar-toggle:hover {
      background: var(--color-hover-secondary);
    }

    .sidebar.collapsed .sidebar-header .sidebar-toggle {
      transform: translateX(2px);
      height: 48px;
      width: 50px;
    }

    .sidebar-toggle span {
      font-size: 1.75rem;
      transition: transform 0.4s ease;
    }

    .sidebar.collapsed .sidebar-toggle span {
      transform: rotate(180deg);
    }

    .sidebar-content {
      flex: 1;
      padding: 20px 18px;
      overflow: hidden auto;
      scrollbar-width: thin;
      scrollbar-color: var(--color-text-placeholder) transparent;
    }

    .sidebar.collapsed .sidebar-content {
      scrollbar-width: none;
    }

    .menu-list {
      display: flex;
      gap: 4px;
      list-style: none;
      flex-direction: column;
      padding: 0;
      margin: 0;
    }

    .menu-link {
      display: flex;
      gap: 12px;
      white-space: nowrap;
      border-radius: 8px;
      padding: 12px 15px;
      align-items: center;
      text-decoration: none;
      color: var(--color-text-primary);
      font-weight: 700;
      transition: 0.3s ease;
    }

    .menu-link .menu-label {
      transition: opacity 0.3s ease;
      font-size: 14px;
    }

    .sidebar.collapsed .menu-link .menu-label {
      opacity: 0;
      pointer-events: none;
    }

    .menu-link:hover,
    .menu-link.active {
      color: #fff;
      background: var(--color-hover-primary);
      box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    }

    .sidebar-footer {
      padding: 20px 18px;
      white-space: nowrap;
      border-top: 1px solid var(--color-border-hr);
    }

    .theme-toggle {
      width: 100%;
      min-height: 48px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      cursor: pointer;
      border: none;
      padding: 0 15px;
      white-space: nowrap;
      color: var(--color-text-primary);
      background: var(--color-bg-secondary);
      transition: 0.3s ease;
      font-weight: 700;
    }

    .theme-toggle:hover {
      background: var(--color-hover-secondary);
    }

    .theme-label {
      display: flex;
      gap: 10px;
      align-items: center;
    }

    .theme-label .theme-text {
      font-size: 1rem;
      transition: opacity 0.4s 0.2s ease;
    }

    .sidebar.collapsed .theme-toggle :where(.theme-text, .theme-toggle-track) {
      opacity: 0;
      width: 0;
      transition: all 0.2s ease;
    }

    .theme-toggle-track {
      height: 24px;
      width: 48px;
      border-radius: 999px;
      margin-right: auto;
      background: #c3d1ec;
      position: relative;
      transition: opacity 0.4s 0.2s ease, background-color 0.3s ease;
    }

    body.dark-theme .theme-toggle-track {
      background: var(--color-hover-primary);
    }

    .theme-toggle-indicator {
      position: absolute;
      top: 3px;
      right: 3px;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background-color: #fff;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      transition: transform 0.3s ease;
    }

    body.dark-theme .theme-toggle-indicator {
      transform: translateX(-24px);
    }

    /* ------------------- */

    /* Main Content */
    .main-area {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      position: relative;
    }

    .content-scroll {
      flex: 1;
      overflow-y: auto;
      padding: 20px;
      padding-bottom: 100px;
      scroll-behavior: smooth;
    }

    /* Mobile Adjustments for Sidebar */
    @media (max-width: 1024px) {
      .sidebar {
        position: fixed;
        right: -270px;
        top: 0;
        height: 100%;
        width: 270px;
        transition: right 0.4s ease;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
      }

      .sidebar.open {
        right: 0;
      }

      .sidebar.collapsed {
        right: -270px;
      }

      /* Disable collapse on mobile, use slide instead */
      .content-scroll {
        padding: 16px;
        padding-bottom: 90px;
      }
    }

    /* Overlay */
    .sidebar-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(4px);
      z-index: 40;
      opacity: 0;
      pointer-events: none;
      transition: 0.3s;
    }

    .sidebar-overlay.active {
      opacity: 1;
      pointer-events: auto;
    }

    /* Premium Cards */
    .glass-card {
      background: var(--color-bg-sidebar);
      border-radius: 24px;
      padding: 20px;
      box-shadow: 0 4px 20px var(--color-shadow);
      border: 1px solid var(--color-border-hr);
      transition: background 0.3s, border 0.3s;
    }

    /* Gradient URL Card */
    .url-card {
      background: linear-gradient(135deg, #2563eb, #8b5cf6);
      border-radius: 24px;
      padding: 24px;
      color: white;
      position: relative;
      overflow: hidden;
      box-shadow: 0 10px 30px rgba(139, 92, 246, 0.2);
    }

    .url-card::before {
      content: '';
      position: absolute;
      top: -50px;
      right: -50px;
      width: 200px;
      height: 200px;
      background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 70%);
      border-radius: 50%;
    }

    .url-card::after {
      content: '';
      position: absolute;
      bottom: -50px;
      left: -50px;
      width: 150px;
      height: 150px;
      background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
      border-radius: 50%;
    }

    /* Topbar */
    .topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 20px;
      background: var(--color-bg-sidebar);
      border-bottom: 1px solid var(--color-border-hr);
      z-index: 30;
      transition: background 0.3s, border 0.3s;
    }

    /* Bottom Nav (Mobile Only) */
    .bottom-nav {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      background: var(--color-bg-sidebar);
      border-top: 1px solid var(--color-border-hr);
      padding-bottom: env(safe-area-inset-bottom);
      display: none;
      z-index: 40;
      transition: background 0.3s, border 0.3s;
    }

    .bottom-nav-inner {
      display: flex;
      justify-content: space-around;
      align-items: center;
      padding: 8px 10px;
      position: relative;
    }

    .nav-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      color: var(--color-text-placeholder);
      font-size: 11px;
      font-weight: 800;
      text-decoration: none;
      padding: 8px;
      flex: 1;
      transition: 0.2s;
    }

    .nav-item i {
      font-size: 20px;
    }

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

    /* FAB Menu */
    .fab-container {
      position: relative;
      top: -24px;
    }

    .fab-btn {
      width: 56px;
      height: 56px;
      border-radius: 50%;
      background: linear-gradient(135deg, #8b5cf6, #3b82f6);
      color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 24px;
      box-shadow: 0 10px 25px rgba(139, 92, 246, 0.4);
      border: 4px solid var(--color-bg-sidebar);
      outline: none;
      cursor: pointer;
      transition: 0.2s;
    }

    .fab-btn:active {
      transform: scale(0.9);
    }

    @media (max-width: 1024px) {
      .bottom-nav {
        display: block;
      }
    }

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

    ::-webkit-scrollbar-track {
      background: transparent;
    }

    ::-webkit-scrollbar-thumb {
      background: #cbd5e1;
      border-radius: 10px;
    }

    body.dark-theme ::-webkit-scrollbar-thumb {
      background: #475569;
    }

    /* Toast */
    #toast-container {
      position: fixed;
      top: 20px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 9999;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .toast {
      background: #1e293b;
      color: white;
      padding: 12px 24px;
      border-radius: 100px;
      font-weight: 800;
      font-size: 13px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
      animation: fadeDown 0.3s ease forwards;
    }

    @keyframes fadeDown {
      from {
        opacity: 0;
        transform: translateY(-20px);
      }

      to {
        opacity: 1;
        transform: translateY(0);
      }
    }