:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --border-color: #30363d;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --accent-primary: #58a6ff;
    --accent-secondary: #1f6feb;
    --success: #3fb950;
    --error: #f85149;
    --warning: #f0a32e;
}

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

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.background-animation {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    background: radial-gradient(ellipse at top, var(--bg-tertiary), var(--bg-primary)), radial-gradient(ellipse at bottom, var(--accent-secondary), var(--bg-primary));
    opacity: 0.3;
}

.background-animation::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image: linear-gradient(var(--border-color) 1px, transparent 1px), linear-gradient(to right, var(--border-color) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.1;
    animation: pan-grid 60s linear infinite;
}

@keyframes pan-grid {
    0% { background-position: 0 0; }
    100% { background-position: 40px 40px; }
}

.header {
    background: rgba(13, 17, 23, 0.8);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container { max-width: 1400px; margin: 0 auto; padding: 0 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.logo-container { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--text-primary); }
.logo-svg { width: 28px; height: 28px; color: var(--accent-primary); }
.logo-container span { font-size: 1.25rem; font-weight: 600; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-link { color: var(--text-secondary); text-decoration: none; font-weight: 500; transition: color 0.2s ease; position: relative; padding: 0.5rem 0; }
.nav-link:hover { color: var(--text-primary); }
.nav-link.active { color: var(--text-primary); font-weight: 600; }
.nav-link.active::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--accent-primary); }
.hamburger-menu { display: none; }

.main-container { max-width: 1400px; width: 100%; margin: 0 auto; padding: 2.5rem 1.5rem; flex-grow: 1; display: flex; flex-direction: column;}

.hero { text-align: center; margin-bottom: 3rem; }
.hero-content { max-width: 700px; margin: 0 auto; }
.hero h1 { font-size: 2.8rem; font-weight: 700; margin-bottom: 1rem; letter-spacing: -1px; }
.hero p { font-size: 1.1rem; color: var(--text-secondary); line-height: 1.6; }

.tool-suite { display: flex; gap: 1.5rem; align-items: flex-start; }
.tool-sidebar { flex: 0 0 240px; position: sticky; top: 80px; }
.tab-group + .tab-group { margin-top: 1.5rem; }
.tab-group-title { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 0.75rem; padding: 0 0.75rem; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.tab-button {
    width: 100%; padding: 0.6rem 0.75rem;
    border: none; border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.95rem; font-weight: 500;
    display: flex; align-items: center; gap: 0.75rem;
    transition: all 0.2s ease;
    text-align: right;
}
.tab-button:hover { background-color: var(--bg-tertiary); color: var(--text-primary); }
.tab-button.active { background-color: var(--accent-primary); color: white; font-weight: 600; }
.tab-button .icon-placeholder svg { width: 20px; height: 20px; fill: currentColor; }

.tool-content-container { flex-grow: 1; min-width: 0; }
.tool-pane { display: none; animation: fadeIn 0.3s ease; }
.tool-pane.active { display: block; }

.tool-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.tool-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.1);
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.tool-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.connection-status { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text-secondary); }
.connection-status-dot { width: 10px; height: 10px; border-radius: 50%; }
.connection-status-dot.connected { background-color: var(--success); animation: pulse-dot 2s infinite; }
.connection-status-dot.disconnected { background-color: var(--error); }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.7); } 70% { box-shadow: 0 0 0 8px rgba(63, 185, 80, 0); } 100% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0); } }

.input-group { margin-bottom: 1.5rem; }
.input-label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-secondary); }
.input-field, .output-field, select.input-field {
    width: 100%; padding: 0.75rem 1rem;
    border-radius: 6px; border: 1px solid var(--border-color);
    background: var(--bg-tertiary); color: var(--text-primary);
    font-family: inherit; font-size: 1rem;
    transition: all 0.2s ease;
}
.input-field:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 4px rgba(88, 166, 255, 0.2); outline: none; }
textarea.input-field, .output-field { font-family: 'Menlo', 'Consolas', monospace; resize: vertical; }
.output-field { min-height: 100px; white-space: pre-wrap; }
.button-group { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.btn { padding: 0.6rem 1rem; border-radius: 6px; font-size: 0.9rem; font-weight: 600; cursor: pointer; border: 1px solid var(--border-color); transition: all 0.2s ease; }
.btn:disabled { cursor: not-allowed; opacity: 0.6; }
.btn-primary { background-image: linear-gradient(to bottom, var(--accent-primary), var(--accent-secondary)); border: none; color: white; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.2); }
.btn:active { transform: scale(0.98); }

.stats-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.stat-card { background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 8px; padding: 1.25rem; }
.stat-card-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.75rem; }
.stat-card-label { font-size: 0.9rem; color: var(--text-secondary); }
.stat-card-value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); font-family: 'Menlo', 'Consolas', monospace; }
.progress-bar-container { width: 100%; height: 8px; background-color: var(--bg-primary); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background-color: var(--accent-primary); border-radius: 4px; transition: width 0.5s ease-out; }

.live-table-container { border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.live-table { width: 100%; border-collapse: collapse; }
.live-table th, .live-table td { padding: 0.8rem 1rem; text-align: right; border-bottom: 1px solid var(--border-color); }
.live-table thead th { background-color: var(--bg-tertiary); font-weight: 600; color: var(--text-secondary); font-size: 0.85rem; }
.live-table tbody tr:last-child td { border-bottom: none; }
.live-table tbody tr:nth-child(even) { background-color: var(--bg-tertiary); }
.live-table td { font-family: 'Menlo', 'Consolas', monospace; font-size: 0.9rem; }
.loading-cell { text-align: center; color: var(--text-secondary); font-family: 'Vazirmatn', sans-serif; }
.status-good { color: var(--success); }
.status-warn { color: var(--warning); }
.status-bad { color: var(--error); }

.speed-test-container { text-align: center; padding: 2rem 0; }
.speed-test-result { font-size: 3rem; font-weight: 700; color: var(--accent-primary); margin-bottom: 1.5rem; font-family: 'Menlo', 'Consolas', monospace; }
#speed-test-start-btn { padding: 0.8rem 1.5rem; font-size: 1rem; }

.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.color-picker-container { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
#color-preview { width: 100px; height: 100px; border-radius: 8px; border: 2px solid var(--border-color); }
#gradient-preview { width: 100%; height: 150px; border-radius: 8px; border: 2px solid var(--border-color); margin-bottom: 1rem; }
#qrcode-output { background: white; padding: 1rem; border-radius: 8px; display: inline-flex; margin-top: 1rem; }
.text-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-top: 1rem; }
.text-info-item { background: var(--bg-tertiary); padding: 1rem; border-radius: 6px; }
.text-info-item .label { color: var(--text-secondary); }
.text-info-item .value { font-weight: 600; font-size: 1.25rem; font-family: 'Menlo', 'Consolas', monospace; }

#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 1000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.8rem 1.2rem; border-radius: 6px; background: var(--bg-tertiary); border: 1px solid var(--border-color); color: var(--text-primary); font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.2); transform: translateX(calc(100% + 1.5rem)); transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1); }
.toast.show { transform: translateX(0); }
.toast-error { border-left: 3px solid var(--error); }
.toast-success { border-left: 3px solid var(--success); }

.footer { padding: 2.5rem 0; text-align: center; margin-top: auto; }
.footer-links { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: 1rem; }
.footer-link { color: var(--text-secondary); text-decoration: none; transition: color 0.2s ease; }
.footer-link:hover { color: var(--accent-primary); }
.copyright { color: var(--text-secondary); font-size: 0.85rem; opacity: 0.7; }

@media (max-width: 992px) {
    .tool-suite { flex-direction: column; }
    .tool-sidebar { position: static; flex: 0 0 auto; width: 100%; }
    .hamburger-menu { display: flex; flex-direction: column; justify-content: space-around; width: 25px; height: 21px; background: transparent; border: none; cursor: pointer; z-index: 110; }
    .nav-links { display: none; position: absolute; top: 65px; left: 0; width: 100%; background: var(--bg-secondary); flex-direction: column; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--border-color); }
    .nav-links.active { display: flex; }
    .grid-2-col { grid-template-columns: 1fr; }
}

.error-page-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-grow: 1;
    padding: 2rem;
}
.error-code {
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 10rem;
    font-weight: 700;
    color: var(--bg-tertiary);
    text-shadow: 0 0 1px var(--border-color), -1px -1px 0 var(--border-color), 1px -1px 0 var(--border-color), -1px 1px 0 var(--border-color), 1px 1px 0 var(--border-color);
    line-height: 1;
    margin-bottom: 1rem;
    animation: fadeIn 1s ease;
}
.error-page-container h1 {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}
.error-page-container p {
    color: var(--text-secondary);
    max-width: 500px;
    margin-bottom: 2rem;
    line-height: 1.7;
}
.error-page-container .btn {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
}

.static-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}
.static-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
}
.static-content p {
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}
.static-content strong {
    color: var(--text-primary);
    font-weight: 600;
}
.styled-list {
    list-style-position: inside;
    padding-right: 1rem;
}
.styled-list li {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}
