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

:root {
    /* Light mode colors */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f9f9f9;
    --bg-rail: #e8e8e8;
    --text-primary: #333;
    --text-secondary: #555;
    --text-tertiary: #666;
    --text-heading: #2c3e50;
    --border-color: #ddd;
    --border-light: #e0e0e0;
    --border-dash: #d0d0d0;
    --shadow: rgba(0,0,0,0.1);
    --shadow-modal: rgba(0,0,0,0.2);
    --hover-bg: rgba(74, 144, 226, 0.1);
    --equipment-bg: #4a90e2;
    --equipment-hover: #357abd;
    --info-bg: #f8f9fa;
    --modal-overlay: rgba(0,0,0,0.5);
}

body.dark-mode {
    /* Dark mode colors */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #252525;
    --bg-rail: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #999;
    --text-heading: #e8e8e8;
    --border-color: #444;
    --border-light: #3a3a3a;
    --border-dash: #404040;
    --shadow: rgba(0,0,0,0.3);
    --shadow-modal: rgba(0,0,0,0.5);
    --hover-bg: rgba(74, 144, 226, 0.2);
    --equipment-bg: #2c5f99;
    --equipment-hover: #3a7abc;
    --info-bg: #252525;
    --modal-overlay: rgba(0,0,0,0.7);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    margin-bottom: 20px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    color: var(--text-heading);
}

.btn-theme {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    min-width: auto;
}

.btn-theme:hover {
    background-color: var(--bg-rail);
}

.theme-icon {
    font-size: 18px;
    display: inline-block;
}

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

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

.control-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

select, input[type="text"], input[type="number"], textarea {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.2s, background-color 0.3s, color 0.3s;
}

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: #4a90e2;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    background-color: #4a90e2;
    color: white;
}

.btn:hover {
    background-color: #357abd;
}

.btn-secondary {
    background-color: #95a5a6;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-primary {
    background-color: #4a90e2;
}

.btn-primary:hover {
    background-color: #357abd;
}

.btn-danger {
    background-color: #e74c3c;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* Rack Styles */
.rack-wrapper {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rack-info {
    margin-bottom: 20px;
    text-align: center;
}

#rack-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-heading);
}

.rack-container {
    position: relative;
    width: 600px;
    background: linear-gradient(to right, var(--bg-rail) 0px, var(--bg-rail) 40px, var(--bg-tertiary) 40px, var(--bg-tertiary) 560px, var(--bg-rail) 560px, var(--bg-rail) 600px);
    padding: 20px 0;
    border-radius: 4px;
    box-shadow: inset 0 2px 4px var(--shadow);
}

.rack-unit {
    display: flex;
    align-items: stretch;
    height: 40px;
    border-bottom: 1px dashed var(--border-dash);
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
}

.rack-unit.occupied {
    cursor: pointer;
    border-bottom: none;
}

.rack-unit:hover:not(.occupied) {
    background-color: var(--hover-bg);
}

.rack-rail {
    width: 40px;
    background: var(--bg-rail);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.rack-rail.left {
    border-right: 1px solid var(--border-color);
}

.rack-rail.right {
    border-left: 1px solid var(--border-color);
}

.rack-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    user-select: none;
}

.rack-space {
    flex: 1;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    padding: 0 15px;
    position: relative;
}

.rack-unit.occupied .rack-space {
    background: var(--equipment-bg);
    color: white;
    font-size: 14px;
    font-weight: 500;
}

.rack-unit.occupied:hover .rack-space {
    background: var(--equipment-hover);
}

.equipment-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
}

.equipment-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.equipment-type {
    font-size: 12px;
    opacity: 0.9;
}

/* Multi-U equipment styling */
.rack-unit.equipment-start .rack-space {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.rack-unit.equipment-end {
    margin-top: 8px;
}

.rack-unit.equipment-end .rack-space {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.rack-unit.equipment-start.equipment-end .rack-space {
    border-radius: 4px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 5% auto;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px var(--shadow-modal);
    animation: slideIn 0.3s;
}

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

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-heading);
}

.close {
    font-size: 28px;
    font-weight: 300;
    color: var(--text-tertiary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

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

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.info-text {
    font-size: 14px;
    color: var(--text-tertiary);
    background: var(--info-bg);
    padding: 10px;
    border-radius: 4px;
    border-left: 3px solid #4a90e2;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Notes Section */
.notes-section {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    margin-top: 20px;
}

.notes-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-secondary);
}

#rack-notes {
    width: 100%;
    min-height: 100px;
    resize: vertical;
}

/* Responsive Design */
@media (max-width: 768px) {
    .rack-container {
        width: 100%;
        max-width: 500px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn {
        width: 100%;
    }
}
