/* ============================================
   NETWORK TOOLKIT - CSS (100 Tools)
   Theme: Dark + Gold Accents
   Bilingual: Persian & English
   ============================================ */

:root {
    --bg: #0a0a0f;
    --surface: #13131a;
    --surface-2: #1a1a24;
    --surface-3: #1e1e2a;
    --border: #252530;
    --text: #e2e2ea;
    --text-muted: #9898a8;
    --gold: #d4a853;
    --gold-light: #e8cc82;
    --gold-dark: #8b6914;
    --gold-bg: rgba(212, 168, 83, 0.08);
    --gold-bg-hover: rgba(212, 168, 83, 0.15);
    --blue: #60a5fa;
    --blue-bg: rgba(96, 165, 250, 0.1);
    --green: #4ade80;
    --green-bg: rgba(74, 222, 128, 0.1);
    --red: #f87171;
    --red-bg: rgba(248, 113, 113, 0.1);
    --purple: #a78bfa;
    --purple-bg: rgba(167, 139, 250, 0.1);
    --orange: #fb923c;
    --orange-bg: rgba(251, 146, 60, 0.1);
    --sidebar-width: 260px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;
    --font-heading: 'Vazirmatn', 'Titr', sans-serif;
    --font-body: 'Vazirmatn', 'IRANSans', 'Tahoma', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.6);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(212, 168, 83, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 80%, rgba(96, 165, 250, 0.03) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   LANGUAGE TOGGLE (FAB)
   ============================================ */
.lang-toggle {
    position: fixed;
    bottom: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

html[dir="rtl"] .lang-toggle {
    left: 20px;
    right: auto;
}
html[dir="ltr"] .lang-toggle {
    left: auto;
    right: 20px;
}

.lang-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(212, 168, 83, 0.3);
    cursor: pointer;
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 13px;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow);
    letter-spacing: 0.5px;
}
.lang-btn:hover {
    border-color: var(--gold-light);
    color: var(--gold-light);
    background: var(--gold-bg);
}
.lang-btn.active {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: #000;
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(212, 168, 83, 0.4);
}

/* ============================================
   PARTICLES
   ============================================ */
.particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.3; }
.particle {
    position: absolute;
    background: var(--gold);
    border-radius: 50%;
    animation: floatUp 12s infinite ease-in;
    opacity: 0;
}
@keyframes floatUp {
    0% { transform: translateY(105vh) scale(0); opacity: 0; }
    15% { opacity: 0.6; }
    50% { opacity: 0.2; }
    85% { opacity: 0.6; }
    100% { transform: translateY(-10vh) scale(1.5); opacity: 0; }
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--surface); border-radius: 10px; }
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--gold), var(--gold-dark));
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, var(--gold-light), var(--gold)); }

/* ============================================
   APP LAYOUT
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    flex-direction: row;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 50;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

html[dir="rtl"] .sidebar {
    right: 0;
    border-left: 1px solid var(--border);
}
html[dir="ltr"] .sidebar {
    left: 0;
    border-right: 1px solid var(--border);
}

html[dir="rtl"] .category-item {
    border-right: 2px solid transparent;
}
html[dir="rtl"] .category-item.active {
    border-right-color: var(--gold);
}
html[dir="ltr"] .category-item {
    border-right: none;
    border-left: 2px solid transparent;
}
html[dir="ltr"] .category-item.active {
    border-left-color: var(--gold);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-family: var(--font-heading);
    font-size: 16px;
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.icon-btn:hover {
    border-color: var(--gold);
    color: var(--gold-light);
    background: var(--gold-bg);
}

#sidebarToggle { display: none; }

/* Search */
.search-box {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 50px;
    color: #fff;
    font-family: var(--font-body);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}
.search-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(212, 168, 83, 0.1);
}
.search-input::placeholder { color: #5a5a6a; }

/* Category Nav */
.category-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    font-size: 13px;
}
.category-item:hover {
    background: var(--gold-bg);
    color: #fff;
}
.category-item.active {
    background: var(--gold-bg);
    color: var(--gold-light);
}
.category-item .cat-icon { font-size: 18px; flex-shrink: 0; }
.category-item .cat-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-item .cat-count {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 50px;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}
.tool-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    padding: 20px 24px;
    min-height: 100vh;
}

html[dir="rtl"] .main-content {
    margin-right: var(--sidebar-width);
    margin-left: 0;
}
html[dir="ltr"] .main-content {
    margin-right: 0;
    margin-left: var(--sidebar-width);
}

/* Menu Button (Mobile) */
.menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    z-index: 60;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--gold-light);
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow);
}

html[dir="rtl"] .menu-btn {
    right: 16px;
    left: auto;
}
html[dir="ltr"] .menu-btn {
    right: auto;
    left: 16px;
}

/* ============================================
   HEADER
   ============================================ */
.tool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 16px;
}

.header-badge {
    display: inline-block;
    background: var(--gold-bg);
    border: 1px solid rgba(212, 168, 83, 0.3);
    color: var(--gold-light);
    padding: 4px 14px;
    border-radius: 50px;
    font-size: 11px;
    font-family: var(--font-mono);
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.header-info h1 {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 900;
    background: linear-gradient(135deg, #fff 0%, var(--gold-light) 50%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.header-info p {
    font-size: 13px;
    color: var(--text-muted);
}

.header-stats {
    display: flex;
    gap: 10px;
}

.stat-badge {
    padding: 8px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   CATEGORY HEADER
   ============================================ */
.category-header {
    margin-bottom: 24px;
}

.category-header h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    color: var(--gold-light);
    margin-bottom: 4px;
}

.category-header p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================
   TOOLS GRID
   ============================================ */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 40px;
}

.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.tool-card:hover {
    border-color: var(--gold);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}
.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0;
    transition: var(--transition);
}
.tool-card:hover::before { opacity: 1; }

.tool-card .card-icon {
    font-size: 28px;
    margin-bottom: 10px;
    display: block;
}
.tool-card .card-name {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}
.tool-card .card-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}

.tool-card.hidden {
    display: none;
}

/* ============================================
   MODAL
   ============================================ */
.tool-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
}
.tool-modal.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    color: var(--gold-light);
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    font-size: 13px;
    color: var(--text-muted);
}

/* Modal Footer — RTL/LTR aware */
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

html[dir="rtl"] .modal-footer {
    flex-direction: row;
}
html[dir="ltr"] .modal-footer {
    flex-direction: row;
}

/* Modal Input Row */
.modal-input-row {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-input-row label {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* RTL: label and input text align right */
html[dir="rtl"] .modal-input-row label {
    text-align: right;
}
html[dir="rtl"] .modal-input-row input,
html[dir="rtl"] .modal-input-row textarea {
    text-align: right;
}

/* LTR: label and input text align left */
html[dir="ltr"] .modal-input-row label {
    text-align: left;
}
html[dir="ltr"] .modal-input-row input,
html[dir="ltr"] .modal-input-row textarea {
    text-align: left;
}

/* Common input/select/textarea styles */
.modal-input-row input,
.modal-input-row select,
.modal-input-row textarea {
    padding: 10px 14px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
    resize: vertical;
}
.modal-input-row input:focus,
.modal-input-row select:focus,
.modal-input-row textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(212, 168, 83, 0.1);
}

/* Technical data inputs always LTR */
.modal-input-row input[data-ltr="true"],
.modal-input-row textarea[data-ltr="true"] {
    direction: ltr !important;
    text-align: left !important;
}

/* Action Button */
.action-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: #fff;
    border: none;
    border-radius: var(--radius-xs);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.action-btn:hover {
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    box-shadow: 0 0 20px rgba(212, 168, 83, 0.3);
}
.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal Result */
.modal-result {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    max-height: 300px;
    overflow-y: auto;
    display: none;
}
.modal-result.visible {
    display: block;
}

/* Result styles */
.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.result-table th,
.result-table td {
    padding: 8px 12px;
    border: 1px solid var(--border);
}
html[dir="rtl"] .result-table th,
html[dir="rtl"] .result-table td {
    text-align: right;
}
html[dir="ltr"] .result-table th,
html[dir="ltr"] .result-table td {
    text-align: left;
}
.result-table th {
    background: var(--surface-2);
    color: var(--gold-light);
    font-family: var(--font-heading);
}
.result-table td {
    color: var(--text);
    font-family: var(--font-mono);
    direction: ltr;
    text-align: left;
}

.result-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 8px;
}
.result-card .rc-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.result-card .rc-value {
    font-family: var(--font-mono);
    font-size: 14px;
    color: #fff;
    direction: ltr;
    text-align: left;
}

.result-raw {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--green);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 250px;
    overflow-y: auto;
    direction: ltr;
    text-align: left;
}

.result-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 50px;
    font-family: var(--font-mono);
    font-size: 11px;
}
.result-status.success { background: var(--green-bg); color: var(--green); }
.result-status.error { background: var(--red-bg); color: var(--red); }
.result-status.warning { background: var(--orange-bg); color: var(--orange); }

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: var(--gold-light);
}
.loading-spinner .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   FOOTER
   ============================================ */
.tool-footer {
    text-align: center;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.tool-footer a {
    color: var(--gold);
    text-decoration: none;
    border-bottom: 1px dotted rgba(212, 168, 83, 0.3);
    transition: var(--transition);
}
.tool-footer a:hover {
    color: var(--gold-light);
    border-bottom-color: var(--gold-light);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    html[dir="rtl"] .sidebar {
        transform: translateX(100%);
    }
    html[dir="ltr"] .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0) !important;
    }
    #sidebarToggle { display: flex; }

    .main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    .menu-btn { display: flex; }

    .lang-toggle {
        bottom: 16px;
        gap: 4px;
    }
    html[dir="rtl"] .lang-toggle {
        left: 12px;
    }
    html[dir="ltr"] .lang-toggle {
        right: 12px;
    }
    .lang-btn {
        width: 38px;
        height: 38px;
        font-size: 11px;
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }

    .tool-card {
        padding: 14px 12px;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .tool-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-info h1 { font-size: 22px; }

    .tools-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .tool-card .card-icon { font-size: 22px; }
    .tool-card .card-name { font-size: 12px; }

    .modal-footer {
        flex-direction: column;
    }
}