/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --bg-body: #000000;
    --bg-card: #1c1c1e;
    --bg-input: #2c2c2e;
    --text-main: #f5f5f7;
    --text-muted: #86868b;
    --accent: #0a84ff;       /* Apple Blue */
    --accent-hover: #0077ed;
    --border: rgba(255, 255, 255, 0.1);
    --glass: rgba(28, 28, 30, 0.75);
    --nav-height: 60px;
    --success: #30d158;
    --danger: #ff453a;
    --warning: #ff9f0a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    padding-top: var(--nav-height);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

/* =========================================
   2. NAVIGATION BAR
   ========================================= */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.logo {
    font-weight: 700;
    font-size: 20px;
    color: var(--text-main);
    letter-spacing: -0.5px;
    text-decoration: none;
    z-index: 5002;
}

/* --- Desktop Menu --- */
.nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
    height: 100%;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.nav-links a:hover { color: var(--text-main); }
.nav-links a.active { color: var(--text-main); }
.nav-links a.btn-login { color: var(--accent); }

/* --- Language Dropdown (Desktop Fix) --- */
.lang-dropdown {
    position: relative;
    display: inline-flex; /* Ensures it sits on the same line */
    align-items: center;
    margin-left: 10px;
    height: auto;
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    /* Remove padding to align baseline with text links */
    padding: 4px 8px;
    margin: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.lang-btn:hover, .lang-btn.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
}

.arrow-icon {
    font-size: 10px;
    opacity: 0.6;
    transition: transform 0.2s ease;
    margin-top: 1px;
}
.lang-btn.active .arrow-icon { transform: rotate(180deg); }

.lang-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    min-width: 150px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    z-index: 9999;
    padding: 5px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.lang-content.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.lang-content a {
    color: var(--text-main);
    padding: 10px 12px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    border-radius: 8px;
    transition: background 0.2s;
    border: none;
}

.lang-content a:hover {
    background-color: var(--accent);
    color: white;
}

/* Mobile Menu Button */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
    z-index: 5002;
}

/* =========================================
   3. LAYOUT & UI COMPONENTS
   ========================================= */
.container { max-width: 1100px; margin: 40px auto; padding: 0 20px; }
h1 { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 10px; margin-top: 0; line-height: 1.2; }
h2 { font-size: 28px; font-weight: 600; margin-top: 40px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
h3 { margin-top: 0; font-size: 20px; font-weight: 600; }
p { color: var(--text-muted); font-size: 17px; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.card {
    background: var(--bg-card);
    border-radius: 18px;
    padding: 24px;
    border: 1px solid var(--border);
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 12px 30px rgba(0,0,0,0.4); border-color: rgba(255,255,255,0.2); }

/* --- Tool Specific Styles (Dashboard) --- */
.tool-link { 
    text-decoration: none; 
    color: white; 
    display: block; 
    border-left: 3px solid var(--accent); 
}
.tool-link h3 { margin-bottom: 6px; }
.tool-link p { font-size: 14px; margin: 0; color: #888; }

.tool-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    object-fit: cover;
}

.arduino-text { color: #00979d !important; }

/* --- Forms --- */
label { display: block; font-size: 12px; color: var(--text-muted); margin-top: 15px; margin-bottom: 6px; text-transform: uppercase; font-weight: 600; }

input, select, textarea {
    width: 100%; padding: 12px 14px; background: var(--bg-input);
    border: 1px solid #3a3a3c; border-radius: 10px; color: white;
    font-size: 16px; font-family: inherit; appearance: none; transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* Buttons */
button {
    background: var(--accent); color: white; border: none; padding: 12px 24px;
    border-radius: 99px; font-size: 15px; font-weight: 600; cursor: pointer;
    margin-top: 20px; width: 100%; transition: background 0.2s, transform 0.1s;
}
button:hover { background: var(--accent-hover); transform: scale(1.02); }
button.secondary { background: #3a3a3c; }
button.secondary:hover { background: #4a4a4c; }

/* Tool Result Box */
.result-box {
    margin-top: 15px; padding: 15px; background: rgba(10, 132, 255, 0.1);
    border-radius: 10px; color: var(--accent); font-family: 'SF Mono', monospace;
    font-size: 14px; min-height: 20px; word-break: break-all; border: 1px solid rgba(10, 132, 255, 0.2);
}

/* =========================================
   4. MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 768px) {
    h1 { font-size: 32px; }
    h2 { font-size: 24px; }
    
    .menu-toggle { display: block; }
    
    /* Full Screen Mobile Menu */
    .nav-links {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        position: fixed;
        top: var(--nav-height);
        left: 0;
        width: 100%;
        height: calc(100vh - var(--nav-height));
        background: #000000;
        padding: 20px;
        padding-bottom: 100px;
        border-top: 1px solid var(--border);
        gap: 0;
        overflow-y: auto;
        z-index: 4999;
    }
    
    .nav-links.active { display: flex; }
    
    .nav-links a {
        font-size: 18px;
        width: 100%;
        padding: 16px 0;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        color: var(--text-main);
        white-space: normal; /* Allow text wrapping on mobile */
    }
    
    /* Mobile Language Dropdown (Accordion) */
    .lang-dropdown {
        width: 100%;
        margin-left: 0;
        margin-top: 20px;
        display: block;
        height: auto;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .lang-btn {
        width: 100%;
        justify-content: space-between;
        background: transparent;
        padding: 16px 0;
        font-size: 18px;
        color: var(--text-main);
        margin: 0;
        border-radius: 0;
    }
    
    .lang-btn:active { background: rgba(255,255,255,0.05); }

    .lang-content {
        position: static;
        width: 100%;
        box-shadow: none;
        background: rgba(255,255,255,0.03);
        border: none;
        padding: 0;
        margin-top: 0;
        backdrop-filter: none;
        border-radius: 0;
        opacity: 1;
        transform: none;
        display: none;
    }
    
    .lang-content.show { display: block; }

    .lang-content a {
        padding: 14px 20px;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        font-size: 16px;
        color: var(--text-muted);
    }

    /* Grid Adjustments */
    .grid { grid-template-columns: 1fr; gap: 20px; }
    
    /* Canvas Fix */
    canvas#schematic-canvas { width: 100% !important; max-height: 400px; }
}