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

:root {
    /* Developer Theme - High Contrast & Clean */
    --bg-primary: #0f1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --bg-card-hover: #222933;

    --border-primary: #30363d;
    --border-secondary: #21262d;

    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --accent-brand: #2f81f7;
    --accent-green: #238636;
    --accent-orange: #d29922;
    --accent-red: #da3633;

    --font-main: 'Tajawal', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-code: 'Fira Code', monospace;

    --shadow-sm: 0 1px 0 rgba(27, 31, 35, 0.04);
    --shadow-md: 0 3px 6px rgba(0, 0, 0, 0.15);

    --radius: 6px;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

/* ===== Layout ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* ===== Header ===== */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    font-family: var(--font-code);
    font-weight: 700;
    font-size: 20px;
    color: var(--accent-brand);
    background: rgba(47, 129, 247, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
}

.logo-text {
    font-weight: 700;
    font-size: 18px;
}

/* ===== Hero / Search ===== */
.toolbar {
    padding: 32px 0;
    border-bottom: 1px solid var(--border-secondary);
    background: var(--bg-primary);
}

.toolbar-inner {
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.search-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 12px 16px 12px 48px;
    border-radius: var(--radius);
    font-family: var(--font-main);
    font-size: 16px;
    transition: all 0.2s;
}

.search-input:focus {
    background: var(--bg-card);
    border-color: var(--accent-brand);
    outline: none;
    box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.15);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.env-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(35, 134, 54, 0.1);
    border: 1px solid rgba(35, 134, 54, 0.3);
    border-radius: var(--radius);
    color: var(--accent-green);
    font-size: 14px;
    font-family: var(--font-code);
}

/* ===== Services Grid ===== */
.main-content {
    padding: 40px 0;
    flex: 1;
}

.category-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin: 40px 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-secondary);
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 16px;
}

/* ===== Developer Card Design ===== */
.dev-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: all 0.2s;
}

.dev-card:hover {
    border-color: var(--text-muted);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.service-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.service-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
}

.service-port {
    font-family: var(--font-code);
    font-size: 12px;
    color: var(--text-muted);
    background: rgba(110, 118, 129, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.health-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 0 2px rgba(35, 134, 54, 0.2);
}

.card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.6;
}

/* URL Copy Section */
.url-box {
    display: flex;
    align-items: center;
    background: #0d1117;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
    font-family: var(--font-code);
    font-size: 12px;
    direction: ltr;
}

.url-text {
    flex: 1;
    padding: 8px 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.copy-btn {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: none;
    border-left: 1px solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn:hover {
    background: var(--bg-card-hover);
}

.copy-success {
    color: var(--accent-green);
}

/* Action Buttons */
.actions {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    margin-top: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-primary {
    background: #238636;
    color: #ffffff;
    border: 1px solid rgba(240, 246, 252, 0.1);
}

.btn-primary:hover {
    background: #2ea043;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

.btn-icon {
    padding: 8px;
    font-size: 14px;
}

/* Footer */
footer {
    border-top: 1px solid var(--border-primary);
    padding: 24px 0;
    margin-top: 40px;
    background: var(--bg-secondary);
    text-align: center;
}

footer p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Keyboard Hint */
.kbd-hint {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-code);
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid var(--border-primary);
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
}

/* Language Switcher & RTL Support */
.lang-switch {
    display: flex;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    margin-inline-end: 16px;
    overflow: hidden;
}

.lang-btn {
    background: none;
    border: none;
    padding: 6px 12px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 13px;
}

.lang-btn.active {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    font-weight: 600;
}

.lang-btn:hover:not(.active) {
    color: var(--text-secondary);
}

/* RTL Overrides */
[dir="rtl"] .search-input {
    padding: 12px 48px 12px 16px;
}

[dir="rtl"] .search-icon {
    left: auto;
    right: 16px;
}

[dir="rtl"] .kbd-hint {
    right: auto;
    left: 16px;
}

[dir="rtl"] .copy-btn {
    border-left: none;
    border-right: 1px solid var(--border-primary);
}

/* Detailed Description Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

[dir="rtl"] .modal-close {
    right: auto;
    left: 16px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-right: 24px;
}

[dir="rtl"] .modal-title {
    padding-right: 0;
    padding-left: 24px;
}

.modal-body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Info Button Style */
.info-btn {
    background: none;
    border: 1px solid var(--border-primary);
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    margin-inline-start: 8px;
    transition: all 0.2s;
}

.info-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

@media (max-width: 768px) {
    .services-grid {
        grid-template-columns: 1fr;
    }

    .toolbar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-panel {
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
    }
}

/* ============================================================
   AI Chat Panel Styles
   ============================================================ */

/* ─── Floating Action Button ──────────────────────────────── */
.ai-fab {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
    box-shadow:
        0 4px 15px rgba(99, 102, 241, 0.4),
        0 0 30px rgba(139, 92, 246, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: ai-fab-glow 3s ease-in-out infinite;
}

.ai-fab:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow:
        0 6px 20px rgba(99, 102, 241, 0.5),
        0 0 40px rgba(139, 92, 246, 0.25);
}

.ai-fab.ai-fab-active {
    transform: scale(0.9);
    opacity: 0.7;
}

.ai-fab-icon {
    font-size: 18px;
    line-height: 1;
}

@keyframes ai-fab-glow {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4), 0 0 30px rgba(139, 92, 246, 0.15);
    }

    50% {
        box-shadow: 0 4px 20px rgba(99, 102, 241, 0.6), 0 0 50px rgba(139, 92, 246, 0.3);
    }
}

[dir="rtl"] .ai-fab {
    left: auto;
    right: 24px;
}

/* ─── Chat Panel ──────────────────────────────────────────── */
.ai-panel {
    position: fixed;
    bottom: 90px;
    left: 24px;
    z-index: 901;
    width: 420px;
    height: 560px;
    display: flex;
    flex-direction: column;
    background: rgba(22, 27, 34, 0.92);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 16px;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(99, 102, 241, 0.1);
    overflow: hidden;

    /* Hidden by default */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-panel.ai-panel-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

[dir="rtl"] .ai-panel {
    left: auto;
    right: 24px;
}

/* ─── Panel Header ────────────────────────────────────────── */
.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.1));
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    flex-shrink: 0;
}

.ai-panel-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.ai-panel-actions {
    display: flex;
    gap: 6px;
}

.ai-close-btn,
.ai-clear-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.ai-close-btn:hover,
.ai-clear-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

/* ─── Messages Area ───────────────────────────────────────── */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.ai-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* ─── Message Bubbles ─────────────────────────────────────── */
.ai-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: ai-msg-in 0.3s ease-out;
}

.ai-msg-user {
    flex-direction: row-reverse;
}

[dir="rtl"] .ai-msg-user {
    flex-direction: row;
}

[dir="rtl"] .ai-msg-bot {
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-msg-body {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-msg-bot .ai-msg-body {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-top-left-radius: 4px;
}

[dir="rtl"] .ai-msg-bot .ai-msg-body {
    border-top-left-radius: 14px;
    border-top-right-radius: 4px;
}

.ai-msg-user .ai-msg-body {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff;
    border-top-right-radius: 4px;
}

[dir="rtl"] .ai-msg-user .ai-msg-body {
    border-top-right-radius: 14px;
    border-top-left-radius: 4px;
}

@keyframes ai-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

/* ─── Typing Indicator ────────────────────────────────────── */
.ai-dots {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

.ai-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: ai-bounce 1.4s ease-in-out infinite;
}

.ai-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ai-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ─── Input Bar ───────────────────────────────────────────── */
.ai-input-bar {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(15, 17, 23, 0.6);
    flex-shrink: 0;
}

.ai-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 10px;
    font-family: var(--font-main);
    font-size: 14px;
    transition: all 0.2s;
}

.ai-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.ai-input::placeholder {
    color: var(--text-muted);
    font-size: 13px;
}

.ai-send-btn {
    padding: 10px 18px;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-send-btn:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

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

/* ─── Markdown Rendering in Chat ──────────────────────────── */
.ai-msg-body p {
    margin: 0 0 6px 0;
}

.ai-msg-body p:last-child {
    margin-bottom: 0;
}

.ai-msg-body h2.ai-h2,
.ai-msg-body h3.ai-h3,
.ai-msg-body h4.ai-h4 {
    margin: 10px 0 4px 0;
    color: var(--text-primary);
}

.ai-msg-body h2.ai-h2 {
    font-size: 15px;
}

.ai-msg-body h3.ai-h3 {
    font-size: 14px;
}

.ai-msg-body h4.ai-h4 {
    font-size: 13px;
}

.ai-msg-body ul {
    margin: 4px 0;
    padding-inline-start: 18px;
}

.ai-msg-body li {
    margin-bottom: 2px;
}

.ai-inline-code {
    background: rgba(99, 102, 241, 0.15);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: var(--font-code);
    font-size: 12px;
    color: #a78bfa;
}

pre.ai-code {
    background: #0d1117;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: var(--font-code);
    font-size: 12px;
    line-height: 1.5;
    color: #e6edf3;
    direction: ltr;
    text-align: left;
}