/* ============================================================
   HARDWAREBASE — Design System
   Premium Technical Interface
   ============================================================ */

/* ---- CSS Variables ---- */
/* ---- CSS Variables ---- */
:root {
    --primary-900: #0F172A;
    --primary-800: #1E293B;
    --primary-700: #334155;
    --primary-600: #475569;
    --primary-500: #64748B;
    --primary-400: #94A3B8;
    --primary-300: #CBD5E1;
    --primary-200: #E2E8F0;
    --primary-100: #F1F5F9;
    --primary-50: #F8FAFC;

    --blue-700: #0D6EFD;
    --blue-600: #2563EB;
    --blue-500: #3B82F6;
    --blue-400: #60A5FA;
    --blue-300: #93C5FD;
    --blue-200: #BFDBFE;
    --blue-100: #DBEAFE;

    --sky-500: #38BDF8;
    --sky-400: #38BDF8;
    --sky-300: #7DD3FC;

    --green-600: #16A34A;
    --green-500: #22C55E;
    --green-100: #DCFCE7;
    --yellow-500: #F59E0B;
    --yellow-100: #FEF3C7;
    --orange-500: #F97316;
    --orange-100: #FFEDD5;
    --red-600: #DC2626;
    --red-500: #EF4444;
    --red-100: #FEE2E2;
    --gray-500: #6B7280;
    --gray-100: #F3F4F6;

    --bg-page: #F5F7FA;
    --bg-card: #FFFFFF;
    --bg-dark: var(--primary-900);
    --text-primary: var(--primary-900);
    --text-secondary: var(--primary-600);
    --text-muted: var(--primary-400);
    --text-light: #FFFFFF;
    --border: var(--primary-200);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.1), 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -2px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --transition: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    --font-en: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-ar: 'Cairo', 'Segoe UI', sans-serif;

    /* Safe Area & Mobile Navigation */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --bottom-nav-height: 62px;
}

/* ---- Reset & Zero Horizontal Overflow System ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    min-width: 0; /* Prevents flex and grid children from overflowing */
}
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-x: clip;
}
body {
    font-family: var(--font-en);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-x: clip;
    position: relative;
}
body[dir="rtl"] { font-family: var(--font-ar); }
body.drawer-open {
    overflow: hidden !important;
    touch-action: none;
}
p, h1, h2, h3, h4, h5, h6, span, a, td, th {
    overflow-wrap: break-word;
    word-break: break-word;
}
img, svg, video, canvas {
    max-width: 100%;
    height: auto;
    display: block;
}
a { color: var(--blue-600); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--blue-700); }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ---- Container System ---- */
.container {
    width: 100%;
    max-width: 1340px;
    margin: 0 auto;
    padding: 0 24px;
}
.container-sm {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}
.container-fluid {
    width: 100%;
    padding: 0 24px;
}

/* ---- Header ---- */
.header {
    background: var(--primary-900);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 64px;
    max-width: 1340px;
    margin: 0 auto;
    gap: 16px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--blue-500), var(--sky-400));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}
.logo-text {
    font-size: 20px;
    font-weight: 800;
    color: white;
    letter-spacing: -0.5px;
    white-space: nowrap;
}
.logo-text span { color: var(--sky-400); }

/* Desktop / Laptop Navigation */
.nav-links {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-wrap: nowrap;
}
.nav-links a {
    color: var(--primary-300);
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active {
    color: white;
    background: rgba(255,255,255,0.08);
}
.nav-links a.active {
    color: var(--sky-400);
    background: rgba(56,189,248,0.1);
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.header-search-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.06);
    color: var(--primary-200);
    transition: all var(--transition);
}
.header-search-btn:hover {
    background: rgba(255,255,255,0.12);
    color: white;
}
.lang-switcher {
    color: var(--primary-300);
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: transparent;
    transition: all var(--transition);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.lang-switcher:hover { color: white; border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.05); }

/* Mobile toggle button */
.mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.06);
    color: white;
    font-size: 20px;
    padding: 0;
    transition: all var(--transition);
}
.mobile-toggle:hover { background: rgba(255,255,255,0.12); }

/* ---- Modern Offcanvas Drawer ---- */
.mobile-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
}
.mobile-drawer-backdrop.open {
    display: block !important;
}
.mobile-drawer {
    display: none;
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(340px, 86vw);
    background: var(--primary-900);
    z-index: 2010;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    transition: transform var(--transition-smooth);
}
[dir="rtl"] .mobile-drawer {
    right: 0;
    transform: translateX(100%);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}
[dir="ltr"] .mobile-drawer {
    left: 0;
    transform: translateX(-100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}
.mobile-drawer.open {
    display: flex !important;
    transform: translateX(0) !important;
}
.mobile-drawer-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.mobile-drawer-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: var(--primary-200);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.mobile-drawer-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}
.mobile-drawer-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px;
}
.mobile-drawer-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary-400);
    padding: 12px 10px 6px;
}
.mobile-drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: var(--primary-200);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition);
    text-decoration: none;
    margin-bottom: 2px;
}
.mobile-drawer-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}
.mobile-drawer-link.active {
    background: rgba(56, 189, 248, 0.12);
    color: var(--sky-400);
    font-weight: 600;
}
.mobile-drawer-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--sky-400);
    flex-shrink: 0;
}
.mobile-drawer-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ---- Mobile Bottom Navigation Bar ---- */
.mobile-bottom-nav {
    display: none; /* hidden by default on desktop/tablet */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 950;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
}
.mobile-bottom-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--bottom-nav-height);
    max-width: 540px;
    margin: 0 auto;
    padding: 0 6px;
}
.mobile-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--primary-400);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 0;
    transition: all var(--transition);
    border-radius: var(--radius-sm);
    -webkit-tap-highlight-color: transparent;
}
.mobile-bottom-nav-item:hover,
.mobile-bottom-nav-item:active {
    color: var(--primary-100);
}
.mobile-bottom-nav-item.active {
    color: var(--sky-400);
}
.bottom-nav-icon-wrap {
    width: 38px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    transition: all var(--transition);
}
.mobile-bottom-nav-item.active .bottom-nav-icon-wrap {
    background: rgba(56, 189, 248, 0.15);
    color: var(--sky-400);
    transform: translateY(-2px);
}

/* ---- Mobile Search Sheet / Modal ---- */
.mobile-search-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--primary-900);
    z-index: 2500;
    flex-direction: column;
}
.mobile-search-modal.open {
    display: flex !important;
}
.mobile-search-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.mobile-search-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}
.mobile-search-input-wrap input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    color: white;
    font-size: 15px;
    outline: none;
}
.mobile-search-input-wrap input:focus {
    border-color: var(--sky-400);
    background: rgba(255, 255, 255, 0.12);
}
.mobile-search-close {
    padding: 8px 12px;
    color: var(--primary-300);
    font-size: 14px;
    font-weight: 600;
}
.mobile-search-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ---- Hero Search ---- */
.hero {
    background: linear-gradient(135deg, var(--primary-900) 0%, #162240 50%, var(--primary-800) 100%);
    padding: 60px 0 70px;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(56,189,248,0.08) 0%, transparent 70%);
    border-radius: 50%;
}
.hero::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(59,130,246,0.06) 0%, transparent 70%);
    border-radius: 50%;
}
.hero-content { position: relative; z-index: 1; text-align: center; }
.hero h1 {
    font-size: 36px;
    font-weight: 800;
    color: white;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}
.hero p {
    font-size: 17px;
    color: var(--primary-300);
    margin-bottom: 30px;
}

.search-box {
    max-width: 720px;
    margin: 0 auto;
    position: relative;
}
.search-box input {
    width: 100%;
    padding: 16px 56px 16px 22px;
    border: 2px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(10px);
    color: white;
    font-size: 16px;
    outline: none;
    transition: all var(--transition);
}
[dir="rtl"] .search-box input { padding: 16px 22px 16px 56px; }
.search-box input::placeholder { color: var(--primary-400); }
.search-box input:focus {
    border-color: var(--blue-500);
    background: rgba(255,255,255,0.1);
    box-shadow: 0 0 0 4px rgba(59,130,246,0.15);
}
.search-box button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--blue-600);
    border: none;
    color: white;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    font-size: 18px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
[dir="rtl"] .search-box button { right: auto; left: 8px; }
.search-box button:hover { background: var(--blue-700); }

/* Autocomplete dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    z-index: 100;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}
.autocomplete-dropdown.open { display: block; }
.ac-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--primary-100);
    color: var(--text-primary);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--primary-50); }
.ac-type {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
}
.ac-type-device { background: var(--blue-100); color: var(--blue-600); }
.ac-type-ic { background: var(--green-100); color: var(--green-600); }
.ac-type-problem { background: var(--red-100); color: var(--red-600); }
.ac-type-connector { background: var(--yellow-100); color: var(--yellow-500); }
.ac-name { font-weight: 600; font-size: 14px; }
.ac-subtitle { font-size: 12px; color: var(--text-muted); }

/* ---- Section ---- */
.section { padding: 48px 0; }
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}
.section-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--blue-600);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ---- Grid ---- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition);
    position: relative;
}
.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--blue-200);
    transform: translateY(-2px);
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--text-primary); }
.card-subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }
.card-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.card-meta span { display: flex; align-items: center; gap: 4px; }

.device-card { display: flex; align-items: flex-start; gap: 16px; }
.device-card-img {
    width: 60px;
    height: 60px;
    border-radius: var(--radius);
    background: var(--primary-50);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    overflow: hidden;
}
.device-card-img img { width: 100%; height: 100%; object-fit: cover; }

.brand-card {
    text-align: center;
    padding: 24px 16px;
}
.brand-card-logo {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    background: var(--primary-50);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--blue-600);
    font-size: 18px;
}
.brand-card-name { font-weight: 700; font-size: 14px; }
.brand-card-count { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---- Compatibility badges ---- */
.compat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}
.compat-compatible { background: var(--green-100); color: var(--green-600); }
.compat-partially_compatible { background: var(--yellow-100); color: var(--yellow-500); }
.compat-requires_modification { background: var(--orange-100); color: var(--orange-500); }
.compat-not_compatible { background: var(--red-100); color: var(--red-600); }
.compat-unknown { background: var(--gray-100); color: var(--gray-500); }

/* Confidence indicator */
.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
}

/* Source badge */
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 3px 8px;
    background: var(--primary-50);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
}
.source-badge:hover { background: var(--blue-100); color: var(--blue-600); }

/* ---- Tables System ---- */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    position: relative;
    max-width: 100%;
}
.tech-table { width: 100%; border-collapse: collapse; }
.tech-table th {
    background: var(--primary-50);
    padding: 12px 16px;
    text-align: start;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.tech-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--primary-100);
    font-size: 14px;
    vertical-align: middle;
}
.tech-table tr:last-child td { border-bottom: none; }
.tech-table tr:hover td { background: var(--primary-50); }

/* ---- Tabs System ---- */
.tabs-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
    padding-bottom: 2px;
}
.tabs-nav::-webkit-scrollbar { display: none; }
.tab-btn {
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -4px;
    white-space: nowrap;
    transition: all var(--transition);
    scroll-snap-align: start;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tab-btn:hover { color: var(--blue-600); }
.tab-btn.active { color: var(--blue-600); border-bottom-color: var(--blue-600); }
.tab-content { display: none; padding-top: 24px; }
.tab-content.active { display: block; }

/* ---- Responsive Counter & Relationship Ribbon ---- */
.counter-ribbon {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    width: 100%;
}
.counter-card {
    padding: 10px 8px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    text-align: center;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.counter-card:hover {
    border-color: var(--blue-300);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}
.counter-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}
.counter-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* ---- Breadcrumbs ---- */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 0;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--blue-600); }
.breadcrumbs .sep { color: var(--primary-300); }
.breadcrumbs .current { color: var(--text-primary); font-weight: 600; }

/* ---- Footer ---- */
.footer {
    background: var(--primary-900);
    color: var(--primary-300);
    padding: 48px 0 24px;
    margin-top: 48px;
}
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; margin-bottom: 32px; }
.footer-title { color: white; font-weight: 700; font-size: 16px; margin-bottom: 16px; }
.footer-links a { display: block; color: var(--primary-400); padding: 4px 0; font-size: 14px; transition: color var(--transition); }
.footer-links a:hover { color: white; }
.footer-desc { font-size: 14px; line-height: 1.7; color: var(--primary-400); }
.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}
.footer-disclaimer {
    font-size: 12px;
    color: var(--primary-500);
    margin-top: 8px;
    max-width: 600px;
}

/* ---- Page Header ---- */
.page-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 24px 0;
}
.page-title { font-size: 28px; font-weight: 800; color: var(--text-primary); }
.page-subtitle { font-size: 15px; color: var(--text-secondary); margin-top: 4px; }

/* ---- Device Page ---- */
.device-header {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    padding: 32px 0;
}
.device-image {
    width: 180px;
    height: 180px;
    border-radius: var(--radius-lg);
    background: white;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    flex-shrink: 0;
    overflow: hidden;
}
.device-info { flex: 1; }
.device-name { font-size: 32px; font-weight: 800; margin-bottom: 4px; }
.device-brand { font-size: 16px; color: var(--blue-600); font-weight: 600; margin-bottom: 12px; }
.device-meta-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.device-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.device-meta-item strong { color: var(--text-primary); }

/* ---- Entity Page ---- */
.entity-section { margin-bottom: 32px; }
.entity-section-title {
    font-size: 18px;
    font-weight: 700;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ---- Sidebar ---- */
.page-with-sidebar { display: grid; grid-template-columns: 1fr 320px; gap: 24px; padding: 32px 0; }
.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}
.sidebar-card-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-card);
    transition: all var(--transition);
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-textarea { resize: vertical; min-height: 100px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-primary { background: var(--blue-600); color: white; }
.btn-primary:hover { background: var(--blue-700); color: white; box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--primary-100); color: var(--text-primary); }
.btn-secondary:hover { background: var(--primary-200); }
.btn-danger { background: var(--red-500); color: white; }
.btn-danger:hover { background: var(--red-600); color: white; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { background: var(--primary-50); border-color: var(--blue-300); }

/* ---- Alerts ---- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: var(--green-100); color: var(--green-600); border: 1px solid #BBF7D0; }
.alert-error { background: var(--red-100); color: var(--red-600); border: 1px solid #FECACA; }
.alert-warning { background: var(--yellow-100); color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: var(--blue-100); color: var(--blue-600); border: 1px solid var(--blue-200); }

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    padding: 24px 0;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.pagination a:hover { background: var(--blue-600); color: white; border-color: var(--blue-600); }
.pagination .active span { background: var(--blue-600); color: white; border-color: var(--blue-600); }
.pagination .disabled span { color: var(--text-muted); background: var(--primary-50); }

/* ---- Admin Panel ---- */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 260px;
    background: var(--primary-900);
    padding: 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.admin-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--primary-300);
    font-size: 14px;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}
[dir="rtl"] .admin-nav a { border-left: none; border-right: 3px solid transparent; }
.admin-nav a:hover { background: rgba(255,255,255,0.05); color: white; }
.admin-nav a.active { background: rgba(59,130,246,0.1); color: var(--blue-400); border-left-color: var(--blue-500); }
[dir="rtl"] .admin-nav a.active { border-left-color: transparent; border-right-color: var(--blue-500); }
.admin-nav-section {
    padding: 10px 20px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary-500);
}
.admin-content { flex: 1; background: var(--bg-page); }
.admin-topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Admin stats */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
}
.stat-value { font-size: 32px; font-weight: 800; color: var(--text-primary); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.stat-trend { font-size: 12px; margin-top: 4px; }

/* ---- AdSense Placeholder ---- */
.ad-slot {
    background: var(--primary-50);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* ============================================================
   RESPONSIVE DESIGN BREAKPOINTS
   Desktop, Laptop, Tablet, and Mobile
   ============================================================ */

/* ---- A. Desktops & Laptops (> 1100px) ---- */
@media (min-width: 1101px) {
    .nav-links { display: flex !important; }
    .mobile-toggle { display: none !important; }
    .mobile-bottom-nav { display: none !important; }
    .header-search-btn { display: none !important; }
    .mobile-drawer { display: none !important; }
    .mobile-drawer-backdrop { display: none !important; }
    .mobile-search-modal { display: none !important; }
}

/* ---- B. Tablets & Small Laptops (769px to 1100px) ---- */
@media (min-width: 769px) and (max-width: 1100px) {
    .nav-links { display: none !important; }
    .mobile-toggle { display: flex !important; }
    .header-search-btn { display: flex !important; }
    .mobile-bottom-nav { display: none !important; }

    .container { padding: 0 20px; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-6 { grid-template-columns: repeat(3, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .page-with-sidebar { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: repeat(2, 1fr); }
    .counter-ribbon { grid-template-columns: repeat(5, 1fr) !important; }
}

/* ---- C. Mobile Devices (<= 768px) ---- */
@media (max-width: 768px) {
    /* Prevent any horizontal overflow */
    html, body {
        overflow-x: hidden !important;
        overflow-x: clip !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    /* Safe bottom padding for fixed bottom navigation bar */
    body {
        padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 14px) !important;
    }

    /* Mobile navigation elements */
    .nav-links { display: none !important; }
    .mobile-toggle { display: flex !important; }
    .mobile-bottom-nav { display: block !important; }
    .header-search-btn { display: flex !important; }
    .header-inner { padding: 0 16px; }

    /* Grids */
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .grid-6 { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .page-with-sidebar { grid-template-columns: 1fr; padding: 20px 0; }

    /* Hero */
    .hero { padding: 36px 0 44px; }
    .hero h1 { font-size: 26px; }
    .hero p { font-size: 15px; margin-bottom: 22px; }

    /* Device Page on Mobile */
    .device-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px 0;
        gap: 16px;
    }
    .device-image {
        width: 130px;
        height: 130px;
        margin: 0 auto;
    }
    .device-name { font-size: 24px; }
    .device-brand { justify-content: center; }
    .device-meta-row { justify-content: center; gap: 10px; }

    /* Relationship / Counter Ribbon on Mobile */
    .counter-ribbon {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 6px !important;
        width: 100% !important;
        margin-top: 1rem !important;
        padding-top: 1rem !important;
        border-top: 1px solid var(--border) !important;
    }
    .counter-card {
        padding: 8px 4px !important;
        min-width: 0 !important;
    }
    .counter-value {
        font-size: 1.1rem !important;
    }
    .counter-label {
        font-size: 0.625rem !important;
    }

    /* Tabs on Mobile */
    .tabs-nav {
        gap: 0;
        padding-bottom: 0;
    }
    .tab-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    /* Footer */
    .footer { padding: 36px 0 20px; margin-top: 36px; }
    .footer-grid { grid-template-columns: 1fr; gap: 24px; }
    .footer-bottom { flex-direction: column; gap: 10px; text-align: center; }

    /* Admin layout on mobile */
    .admin-sidebar { display: none; }
    .admin-layout { display: block; }
    .section-header { flex-direction: column; gap: 8px; align-items: flex-start; }

    /* Table → Adaptive Cards on Mobile */
    .mobile-card-table thead { display: none; }
    .mobile-card-table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: 12px 14px;
        margin-bottom: 12px;
        background: var(--bg-card);
        box-shadow: var(--shadow-sm);
    }
    .mobile-card-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid var(--primary-100);
        font-size: 13.5px;
        gap: 12px;
    }
    .mobile-card-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-secondary);
        font-size: 12.5px;
        flex-shrink: 0;
    }
    .mobile-card-table td:last-child { border-bottom: none; }

    /* Schematic viewer stage */
    #schematic-canvas-wrapper {
        min-height: 320px !important;
        padding: 0.5rem !important;
    }
    #schematic-view-controls {
        width: 100%;
    }
    #schematic-view-controls .btn {
        flex: 1 1 calc(50% - 0.5rem);
        font-size: 11.5px;
        padding: 6px 8px;
        text-align: center;
        justify-content: center;
    }
}

/* ---- D. Small Mobile Phones (<= 480px) ---- */
@media (max-width: 480px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .grid-6 { grid-template-columns: repeat(2, 1fr); }
    .container { padding: 0 14px; }
    .hero h1 { font-size: 22px; }
    .hero p { font-size: 14px; }
    .search-box input { font-size: 14px; padding: 13px 44px 13px 14px; }
    [dir="rtl"] .search-box input { padding: 13px 14px 13px 44px; }
    .page-title { font-size: 22px; }
    .device-name { font-size: 20px; }
    .counter-ribbon {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
    }
    .counter-card { min-width: 0 !important; }
    .counter-value { font-size: 1.05rem !important; }
    .counter-label { font-size: 0.6rem !important; }
}

/* ---- E. Ultra-compact Screens (<= 360px) ---- */
@media (max-width: 360px) {
    .container { padding: 0 10px; }
    .logo-text { font-size: 17px; }
    .logo-icon { width: 32px; height: 32px; font-size: 14px; }
    .mobile-bottom-nav-item { font-size: 10px; }
    .bottom-nav-icon-wrap { width: 32px; height: 26px; }
    .counter-ribbon {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ---- Loading animation ---- */
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
.loading { animation: pulse 1.5s ease-in-out infinite; }

/* ---- Smooth transitions ---- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease-out; }


/* App Button */
.app-btn-nav { color: #38BDF8; padding: 6px 14px; border: 1px solid rgba(56, 189, 248, 0.4); border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; background: rgba(56, 189, 248, 0.1); transition: all var(--transition); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.app-btn-nav:hover { color: #FFFFFF; background: #2563EB; border-color: #2563EB; box-shadow: 0 0 15px rgba(37, 99, 235, 0.5); transform: translateY(-1px); }
.mobile-drawer-app-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px; border-radius: var(--radius); background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(56, 189, 248, 0.12)); border: 1px solid rgba(56, 189, 248, 0.3); color: var(--blue-600); font-weight: 700; font-size: 14px; text-decoration: none; transition: all var(--transition); }
.mobile-drawer-app-link:hover { background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(56, 189, 248, 0.2)); border-color: var(--blue-500); }
.badge-app-new { margin-inline-start: auto; background: #22C55E; color: #FFFFFF; font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 700; }
