<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}Multi-Plant ERP{% endblock %}</title>
    {% load static %}
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary: #2563eb;
            --primary-hover: #1d4ed8;
            --bg-main: #f1f5f9;
            --bg-card: #ffffff;
            --text-main: #0f172a;
            --text-muted: #64748b;
            --border: #e2e8f0;
            --sidebar-width: 260px;
        }

        body {
            font-family: 'Inter', sans-serif;
            background-color: var(--bg-main);
            color: var(--text-main);
            margin: 0;
            display: flex;
            min-height: 100vh;
        }

        /* Sidebar */
        .sidebar {
            width: var(--sidebar-width);
            background: #1e293b;
            color: white;
            position: fixed;
            height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .sidebar-header {
            padding: 2rem 1.5rem;
            font-size: 1.25rem;
            font-weight: 700;
            letter-spacing: -0.025em;
            border-bottom: 1px solid #334155;
        }

        .nav-links {
            flex: 1;
            padding: 1.5rem 1rem;
        }

        .nav-link {
            display: flex;
            align-items: center;
            padding: 0.75rem 1rem;
            color: #94a3b8;
            text-decoration: none;
            border-radius: 8px;
            margin-bottom: 0.5rem;
            transition: all 0.2s;
            font-weight: 500;
        }

        .nav-link:hover, .nav-link.active {
            background: #334155;
            color: white;
        }

        /* Main Content */
        .main-wrapper {
            margin-left: var(--sidebar-width);
            flex: 1;
            display: flex;
            flex-direction: column;
        }

        .top-bar {
            height: 64px;
            background: white;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: flex-end;
            padding: 0 2rem;
            position: sticky;
            top: 0;
            z-index: 10;
        }

        .content-area {
            padding: 2rem;
            max-width: 1400px;
            margin: 0 auto;
            width: 100%;
            box-sizing: border-box;
        }

        /* Common Components */
        .card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        }

        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0.625rem 1.25rem;
            border-radius: 8px;
            font-weight: 600;
            font-size: 0.875rem;
            cursor: pointer;
            transition: all 0.2s;
            text-decoration: none;
            border: none;
        }

        .btn-primary {
            background: var(--primary);
            color: white;
        }

        .btn-primary:hover {
            background: var(--primary-hover);
        }

        {% block extra_css %}{% endblock %}
    </style>
    {% block head %}{% endblock %}
</head>
<body>
    <aside class="sidebar">
        <div class="sidebar-header">
            Manufacturing ERP
        </div>
        <nav class="nav-links">
            <a href="{% url 'home' %}" class="nav-link">Dashboard</a>
            <a href="#" class="nav-link">Facilities</a>
            <a href="#" class="nav-link">Inventory</a>
            <a href="#" class="nav-link">Work Orders</a>
            <a href="#" class="nav-link">Machines</a>
            <a href="#" class="nav-link">Quality Control</a>
        </nav>
        <div style="padding: 1.5rem; border-top: 1px solid #334155;">
            <a href="/admin/" class="nav-link" style="font-size: 0.875rem;">Admin Panel</a>
        </div>
    </aside>

    <div class="main-wrapper">
        <header class="top-bar">
            <div style="display: flex; align-items: center; gap: 1rem;">
                <span style="font-size: 0.875rem; color: var(--text-muted);">{{ user.username }}</span>
                <div style="width: 32px; height: 32px; background: #e2e8f0; border-radius: 50%;"></div>
            </div>
        </header>

        <main class="content-area">
            {% block content %}{% endblock %}
        </main>
    </div>
</body>
</html>