/* ==============================================================================
   MANUFACTURER OPERATIONS PORTAL - DESIGN SYSTEM & STYLESHEET
   Sleek Dark Theme | Glassmorphism | Industrial IoT Aesthetics
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

:root {
    --bg-base: #080c14;
    --bg-surface: #0e1526;
    --bg-card: rgba(16, 24, 43, 0.85);
    --bg-card-hover: rgba(23, 34, 61, 0.95);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(59, 130, 246, 0.3);
    
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.25);
    --primary-dark: #1d4ed8;
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --cyan: #06b6d4;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Background Ambient Glows */
.ambient-glow-1 {
    position: fixed;
    top: -150px;
    left: 20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.ambient-glow-2 {
    position: fixed;
    bottom: -150px;
    right: 10%;
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.09) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    box-shadow: 0 0 15px var(--primary-glow);
}

.brand-text h1 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-primary);
}

.brand-text p {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Navigation Links */
.sidebar-nav {
    flex: 1;
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 0.75rem 0.75rem 0.25rem 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: 1px solid transparent;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.25);
    font-weight: 600;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.user-meta .name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-meta .role {
    font-size: 0.65rem;
    color: var(--success);
    font-weight: 500;
}

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

/* Top Header Bar */
.top-header {
    height: var(--header-height);
    background: rgba(14, 21, 38, 0.7);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-title h2 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
}

.header-title p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Content Container */
.content-body {
    padding: 2rem;
    flex: 1;
}

/* Tabs */
.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==============================================================================
   METRIC STAT CARDS
   ============================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-accent);
    background: var(--bg-card-hover);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.stat-icon.cyan { background: rgba(6, 182, 212, 0.15); color: var(--cyan); }

.stat-info .stat-value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-info .stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==============================================================================
   TABLES & DATA CARDS
   ============================================================================== */
.card-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.panel-header h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
}

.panel-header p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.panel-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Data Table */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
}

.data-table th {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.8px;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-offline {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
    border: 1px solid rgba(100, 116, 139, 0.25);
}

.badge-pulse {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.badge-module {
    padding: 0.2rem 0.5rem;
    font-size: 0.65rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    margin-right: 0.35rem;
}

.badge-module.on {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-module.off {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

/* ==============================================================================
   BUTTONS & INPUTS
   ============================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.825rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 12px var(--primary-glow);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(239, 68, 68, 0.5);
}

.btn-outline-primary {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.btn-outline-primary:hover {
    background: rgba(59, 130, 246, 0.22);
    border-color: rgba(59, 130, 246, 0.5);
}

.actions-cell {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
}


.input-field {
    background: rgba(14, 21, 38, 0.8);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 0.6rem 0.85rem;
    font-size: 0.825rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    vertical-align: middle;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .25s;
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: .25s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(16px);
    background-color: white;
}

/* ==============================================================================
   MODAL WINDOWS
   ============================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(4, 7, 13, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 520px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform var(--transition-normal);
}

.modal-overlay.open .modal-container {
    transform: scale(1);
}

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

.modal-header h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.15);
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 2000;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(50px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.mono-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: #60a5fa;
}
