:root {
    --bg-color: #f8fafc;
    --sidebar-bg: #0f172a;
    --card-bg: #ffffff;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Shared */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 2rem 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-area i {
    font-size: 1.5rem;
    color: var(--primary);
}

.sidebar-close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-links {
    list-style: none;
    padding: 0 0.75rem;
}

.nav-links li {
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-links li a {
    color: #94a3b8;
    text-decoration: none;
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    font-size: 0.9375rem;
}

.nav-links li:hover, .nav-links li.active {
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-links li:hover a, .nav-links li.active a {
    color: white;
}

.nav-links li.active {
    background-color: var(--primary);
}

/* Main Content Shared */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2.5rem 3.5rem;
    max-width: calc(100vw - var(--sidebar-width));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed + .main-content {
    margin-left: 0;
    max-width: 100vw;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.sidebar-toggle-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.sidebar.collapsed + .main-content .sidebar-toggle-btn {
    display: flex;
}

.sidebar-toggle-btn:hover {
    background: #f1f5f9;
    border-color: var(--primary);
    color: var(--primary);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

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

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 300px;
    background: var(--card-bg);
    font-family: inherit;
    font-size: 0.875rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    width: 380px;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.625rem 1.25rem;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.user-profile i {
    font-size: 1.25rem;
    color: var(--primary);
}

/* Common Section styles */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
}

.header-main {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.floor-filters {
    display: flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
}

.filter-btn {
    border: none;
    background: transparent;
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    color: var(--text-main);
}

.filter-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* SPA Navigation */
.page {
    display: none;
    flex: 1;
}

.page.active {
    display: flex;
    flex-direction: column;
}

/* Dashboard Specific */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.75rem;
    margin-bottom: 3rem;
}

.stat-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.table-container {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: auto;
    flex: 1;
}

/* Tables Shared */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

th:last-child, td:last-child {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}

td {
    padding: 1.25rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}

tr:hover td {
    background-color: #f8fafc;
}

.empty-state {
    text-align: center !important;
    padding: 5rem 1rem !important;
    color: var(--text-muted);
    vertical-align: middle;
    width: 100%;
}

.empty-state i {
    display: block;
    font-size: 3.5rem;
    margin-bottom: 1.25rem;
    opacity: 0.2;
}

.empty-state p {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
}

/* Modal Shared */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    padding: 1rem;
    overflow: hidden;
    align-items: center;
    justify-content: center;
}

.modal[style*="display: block"] {
    display: flex !important;
}

.modal-content {
    background: var(--card-bg);
    max-width: 950px;
    width: 100%;
    margin: 0;
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
    position: relative;
    box-shadow: var(--shadow-lg);
    max-height: 98vh;
    overflow: hidden;
}

.modal-content h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.modal-content h3 {
    font-size: 1rem;
    margin: 1rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--primary);
}

.close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.form-group label, .form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.form-group input[readonly] {
    background: #f8fafc;
    color: var(--text-muted);
}

/* Buttons Shared */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem 2rem;
    border-top: 1px solid var(--border);
    background: #fcfdfe;
    margin-left: -2rem;
    margin-right: -2rem;
    margin-bottom: -1.5rem;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    filter: brightness(0.9);
}

.confirm-modal-content {
    max-width: 400px;
    text-align: center;
    padding: 2.5rem;
}

.confirm-icon {
    font-size: 3rem;
    color: var(--danger);
    margin-bottom: 1.5rem;
}

.confirm-modal-content h2 {
    margin-bottom: 0.75rem;
}

.confirm-modal-content p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.confirm-modal-content .form-actions {
    justify-content: center;
    margin-top: 2rem;
    padding: 1.5rem 0 0 0;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 0;
    background: transparent;
    border-top: 1px solid var(--border);
}

.btn-action {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    margin-right: 0.5rem;
    transition: all 0.2s ease;
}

.btn-action:last-child {
    margin-right: 0;
}

.btn-view { background: rgba(99, 102, 241, 0.1); color: var(--primary); }
.btn-view:hover { background: var(--primary); color: white; }

.btn-edit { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.btn-edit:hover { background: var(--warning); color: white; }

.btn-delete { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.btn-delete:hover { background: var(--danger); color: white; }

/* Details Grid Shared */
.details-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem 1.5rem;
    background: #f8fafc;
    padding: 1.5rem 2rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.detail-section-title {
    grid-column: 1 / -1;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: 0.1em;
    margin-top: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.detail-item label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.detail-item span {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-main);
}



.stat-card {
    background: var(--card-bg);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.25rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-card i {
    font-size: 1.75rem;
    width: 4rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border-radius: var(--radius-md);
    margin: 0 auto;
}

.stat-info h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-info p {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
}

.dashboard-bottom-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.75rem;
}

.network-stat-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

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

/* Systems Specific */
.components-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    background: #f1f5f9;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px dashed #cbd5e1;
}

.component-item {
    background: var(--card-bg);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.component-item label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--secondary);
    margin-bottom: 0.25rem;
    display: block;
    letter-spacing: 0.05em;
}

.component-item input {
    width: 100%;
    border: none;
    background: transparent;
    font-weight: 700;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--primary);
    padding: 0;
    outline: none;
}

/* RAM Selector */
.ram-selector {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 4px;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.ram-selector button {
    padding: 6px 0;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ram-selector button:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.ram-selector button.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

/* Transitions */
.content-section {
    animation: fadeInSlide 0.4s ease forwards;
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

@media (max-width: 768px) {
    .sidebar { width: 80px; }
    .sidebar-header span, .nav-links span { display: none; }
    .main-content { margin-left: 80px; padding: 1.5rem; }
    .form-grid, .details-grid { grid-template-columns: 1fr; }
    .dashboard-bottom-grid { grid-template-columns: 1fr; }
}

/* Sections Grid Layout */
.sections-grid-container {
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
}

.floor-group {
    margin-bottom: 2.5rem;
}

.floor-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 1.25rem;
    letter-spacing: 0.05em;
    padding-left: 0.5rem;
}

.sections-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
}

.section-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid #f1f5f9;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px;
}

.section-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.section-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.section-card-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
    max-width: 70%;
}

.section-card-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0.4;
    transition: opacity 0.2s ease;
}

.section-card:hover .section-card-actions {
    opacity: 1;
}

.btn-icon-only {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    font-size: 0.875rem;
    transition: color 0.2s ease;
}

.btn-icon-only:hover {
    color: var(--primary);
}

.btn-icon-only:hover .fa-trash {
    color: var(--danger);
}

.section-card-footer {
    margin-top: 1rem;
}

.section-badge {
    background: #eff6ff;
    color: #3b82f6;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.floor-group:nth-child(2n) .section-badge {
    background: #f5f3ff;
    color: #8b5cf6;
}

.floor-group:nth-child(3n) .section-badge {
    background: #fff7ed;
    color: #f59e0b;
}

/* Replacement History Styles */
#replacements-list tr td {
    vertical-align: middle;
}

#replacements-list .text-muted {
    font-size: 0.8rem;
    color: #94a3b8;
}

#replacements-list .text-success {
    color: var(--success);
}

.fa-exchange-alt {
    margin-right: 8px;
}
