/* Engineering Hub - NetBox-inspired styling with Dark/Light mode */

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

/* Light Mode Variables */
:root, .light-mode {
    --sidebar-bg: #1e2a38;
    --sidebar-hover: #2a3a4d;
    --sidebar-active: #3a4d63;
    --sidebar-text: #8fa4b8;
    --sidebar-text-active: #ffffff;
    --sidebar-border: rgba(255,255,255,0.1);
    
    --content-bg: #f5f7fa;
    --card-bg: #ffffff;
    --card-border: #dce1e7;
    --table-header-bg: #fafbfc;
    
    --text-primary: #2c3e50;
    --text-secondary: #6c7a89;
    --text-muted: #95a5a6;
    
    --input-bg: #ffffff;
    --input-border: #dce1e7;
    
    --accent: #0d6efd;
    --accent-hover: #0b5ed7;
    --success: #198754;
    --warning: #fd7e14;
    --danger: #dc3545;
    --info: #0dcaf0;
}

/* Dark Mode Variables */
.dark-mode {
    --sidebar-bg: #0f1419;
    --sidebar-hover: #1c2732;
    --sidebar-active: #253341;
    --sidebar-text: #8b98a5;
    --sidebar-text-active: #f7f9f9;
    --sidebar-border: #38444d;
    
    --content-bg: #15202b;
    --card-bg: #192734;
    --card-border: #38444d;
    --table-header-bg: #1c2732;
    
    --text-primary: #f7f9f9;
    --text-secondary: #8b98a5;
    --text-muted: #6e767d;
    
    --input-bg: #273340;
    --input-border: #38444d;
    
    --accent: #1d9bf0;
    --accent-hover: #1a8cd8;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--content-bg);
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 24px;
    color: var(--accent);
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.5px;
}

/* Sidebar Search */
.sidebar-search {
    padding: 12px;
}

.search-trigger {
    width: 100%;
    padding: 8px 12px;
    background: var(--sidebar-hover);
    border: 1px solid var(--sidebar-border);
    border-radius: 6px;
    color: var(--sidebar-text);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
}

.search-trigger kbd {
    margin-left: auto;
    padding: 2px 6px;
    background: var(--sidebar-bg);
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
}

.search-trigger:hover {
    background: var(--sidebar-active);
}

.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.nav-item-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.nav-label {
    font-size: 13px;
    font-weight: 500;
}

/* Nav Section */
.nav-section {
    border-top: 1px solid var(--sidebar-border);
    margin-top: 12px;
    padding-top: 12px;
}

.nav-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-section-edit {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 12px;
}

.nav-section-edit:hover {
    color: var(--sidebar-text-active);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
}

/* Theme Toggle */
.theme-toggle-form {
    margin-bottom: 12px;
}

.theme-toggle {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--sidebar-border);
    border-radius: 6px;
    color: var(--sidebar-text);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.theme-toggle:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--sidebar-text);
    margin-bottom: 12px;
}

.user-icon {
    color: var(--success);
}

.user-name {
    font-size: 13px;
}

.logout-btn {
    display: block;
    padding: 8px 12px;
    background: var(--sidebar-hover);
    border: 1px solid var(--sidebar-border);
    border-radius: 4px;
    color: var(--sidebar-text);
    text-decoration: none;
    text-align: center;
    font-size: 12px;
    transition: all 0.15s ease;
}

.logout-btn:hover {
    background: var(--sidebar-active);
    color: #fff;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 220px;
    min-height: 100vh;
}

/* Announcement Banner */
.announcement {
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.announcement-info {
    background: #cff4fc;
    border-bottom: 1px solid #0dcaf0;
    color: #055160;
}

.announcement-warning {
    background: #fff3cd;
    border-bottom: 1px solid #ffc107;
    color: #664d03;
}

.announcement-critical {
    background: #f8d7da;
    border-bottom: 1px solid #dc3545;
    color: #842029;
}

.dark-mode .announcement-warning {
    background: #332701;
    color: #ffc107;
}

.dark-mode .announcement-critical {
    background: #2c0b0e;
    color: #f8d7da;
}

/* Top Bar */
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.breadcrumb {
    font-size: 13px;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span:not(:last-child)::after {
    content: " / ";
    color: var(--text-muted);
    margin: 0 4px;
}

/* Content Area */
.content {
    padding: 24px;
}

/* Flash Messages */
.flash-messages {
    padding: 0 24px;
    margin-top: 16px;
}

.flash {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.flash-success {
    background: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

.flash-error {
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

.flash-info {
    background: #cff4fc;
    color: #055160;
    border: 1px solid #b6effb;
}

.flash-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.5;
    color: inherit;
}

.flash-close:hover {
    opacity: 1;
}

/* Quick Links Bar */
.quick-links-bar {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.quick-links-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 8px;
}

.quick-link-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--table-header-bg);
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s ease;
}

.quick-link-chip:hover {
    background: var(--accent);
    color: #fff;
}

.quick-link-edit {
    margin-left: auto;
    padding: 6px 12px;
    background: transparent;
    border: 1px dashed var(--card-border);
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
}

.quick-link-edit:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    margin-bottom: 16px;
}

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

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 16px;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--card-border);
}

th {
    background: var(--table-header-bg);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

tr:hover td {
    background: var(--table-header-bg);
}

td a {
    color: var(--accent);
    text-decoration: none;
}

td a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

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

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #5c636a;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #157347;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--table-header-bg);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-primary);
    transition: border-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.form-control-sm {
    padding: 6px 10px;
    font-size: 13px;
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-primary { background: var(--accent); color: #fff; }
.badge-success { background: var(--success); color: #fff; }
.badge-warning { background: var(--warning); color: #fff; }
.badge-danger { background: var(--danger); color: #fff; }
.badge-secondary { background: #6c757d; color: #fff; }
.badge-info { background: var(--info); color: #000; }

.badge-open { background: #0d6efd; color: #fff; }
.badge-in-progress { background: #fd7e14; color: #fff; }
.badge-completed { background: #198754; color: #fff; }
.badge-closed { background: #6c757d; color: #fff; }

.badge-high { background: #dc3545; color: #fff; }
.badge-medium { background: #fd7e14; color: #fff; }
.badge-low { background: #6c757d; color: #fff; }

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 20px;
    border-left: 3px solid var(--accent);
}

.stat-card-blue { border-left-color: #0d6efd; }
.stat-card-orange { border-left-color: #fd7e14; }
.stat-card-green { border-left-color: #198754; }
.stat-card-purple { border-left-color: #6f42c1; }

.stat-value {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dashboard-sidebar .card {
    margin-bottom: 0;
}

/* Activity Feed */
.activity-feed {
    padding: 8px;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--card-border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--table-header-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.activity-item-title {
    font-size: 13px;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.activity-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
}

/* Tool Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.tool-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.tool-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.tool-icon {
    width: 44px;
    height: 44px;
    background: var(--table-header-bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.tool-info h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.tool-info p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

.tool-arrow {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 18px;
}

/* Notes */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 16px;
}

.note-card.pinned {
    border-left: 3px solid var(--warning);
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.note-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.note-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.note-meta {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}

/* KB Articles */
.kb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.kb-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 20px;
    transition: all 0.15s ease;
}

.kb-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.kb-category {
    margin-bottom: 8px;
}

.kb-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.kb-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.kb-title a:hover {
    color: var(--accent);
}

.kb-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Search */
.search-box {
    position: relative;
    max-width: 300px;
}

.search-box input {
    padding-left: 36px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-message {
    font-size: 14px;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2a38 0%, #2c3e50 100%);
}

.login-card {
    background: #fff;
    border-radius: 8px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .logo-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

.login-header p {
    color: #6c7a89;
    font-size: 14px;
    margin-top: 4px;
}

/* Global Search Modal */
.search-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 120px;
}

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

.search-modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: 12px;
    width: 600px;
    max-width: 90%;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4);
    border: 1px solid var(--card-border);
}

.search-input-wrapper {
    padding: 16px;
    border-bottom: 1px solid var(--card-border);
}

.search-input-wrapper input {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.search-hint {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
}

.search-result-item:hover {
    background: var(--table-header-bg);
}

.search-result-icon {
    color: var(--text-muted);
}

.search-result-title {
    flex: 1;
}

.search-result-type {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.search-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--card-border);
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}

.search-footer kbd {
    padding: 2px 6px;
    background: var(--table-header-bg);
    border-radius: 4px;
    margin-right: 4px;
}

/* Inline actions */
.inline-actions {
    display: flex;
    gap: 4px;
}

.inline-actions form {
    display: inline;
}

/* Responsive */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    
    .sidebar-header, .sidebar-footer, .nav-label, .user-name, .sidebar-search, .nav-section {
        display: none;
    }
    
    .main-content {
        margin-left: 60px;
    }
    
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    
    .nav-icon {
        font-size: 18px;
    }
    
    .quick-links-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
}
