/* Rack Power Calculator – Local Styles */

.rack-grid {
    display: grid;
    grid-template-columns: 320px 1fr 350px;
    gap: 20px;
    height: calc(100vh - 140px);
    min-height: 600px;
    padding: 20px 100px;
    box-sizing: border-box;
}

.panel-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.inner-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

.inner-card h3 {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 16px;
    font-weight: 600;
}

/* Force dark color-scheme so native browser controls (dropdowns, checkboxes, number spinners) render in dark mode */
input[type="number"],
input[type="checkbox"],
select {
    color-scheme: dark;
}

/* Settings */
.setting-row {
    margin-bottom: 8px;
}

.setting-label {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 4px;
    display: block;
}

/* Small Icon Buttons */
.btn-icon-sm {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--text);
    opacity: 0.7;
    cursor: pointer;
    background: transparent;
    border: none;
}

.btn-icon-sm:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.btn-icon-sm:disabled {
    opacity: 0.3;
    cursor: default;
}

.btn-icon-sm:disabled:hover {
    background: transparent;
    opacity: 0.3;
}

/* Action Buttons (modal, tree) */
.btn-action {
    background: rgba(255, 255, 255, 0.08);
    color: #eaf1f6;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 14px;
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.14);
}

.btn-action.btn-danger {
    background: linear-gradient(135deg, #E85D5D 0%, #d14545 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(232, 93, 93, 0.3);
}

/* Small text buttons for tree actions */
.tree-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 12px;
}

.btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-sm:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
}

.btn-sm:disabled {
    opacity: 0.35;
    cursor: default;
}

/* ===== Tree View ===== */
.tree-root {
    font-size: 13px;
}

.tree-node {
    user-select: none;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.tree-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.tree-row.selected {
    background: rgba(74, 168, 181, 0.18);
}

.tree-row .material-icons-outlined {
    font-size: 18px;
    opacity: 0.7;
}

.tree-toggle {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0.5;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s;
    border: none;
    background: none;
    color: inherit;
    padding: 0;
}

.tree-toggle.collapsed {
    transform: rotate(-90deg);
}

.tree-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-rename-btn {
    display: none;
    width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.45;
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
    padding: 0;
}
.tree-rename-btn:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.tree-row:hover .tree-rename-btn,
.tree-row.selected .tree-rename-btn { display: inline-flex; }

.tree-label-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(74, 168, 181, 0.4);
    color: var(--text);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.tree-children {
    padding-left: 18px;
}

.tree-children.collapsed {
    display: none;
}

.tree-badge {
    font-size: 10px;
    opacity: 0.5;
    margin-left: 4px;
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 6px;
    border-radius: 4px;
}

/* Inline rename button */
.tree-row .btn-rename {
    opacity: 0;
    transition: opacity 0.15s;
    width: 20px;
    height: 20px;
    font-size: 14px;
}

.tree-row:hover .btn-rename {
    opacity: 0.5;
}

.tree-row:hover .btn-rename:hover {
    opacity: 1;
}

/* ===== Device Table ===== */
.comp-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
}

.comp-table th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    opacity: 0.7;
    padding: 0 8px 8px 8px;
}

.comp-table td {
    padding: 0;
}

.comp-row {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    transition: background 0.2s;
}

.comp-row:hover {
    background: rgba(255, 255, 255, 0.08);
}

.comp-row.selected {
    background: rgba(74, 168, 181, 0.15);
    border: 1px solid rgba(74, 168, 181, 0.3);
}

.comp-row input,
.comp-row select {
    background: transparent;
    border: none;
    color: var(--text);
    width: 100%;
    padding: 8px;
    font-family: inherit;
}

.comp-row input:focus,
.comp-row select:focus {
    outline: none;
    background: rgba(0, 0, 0, 0.2);
}

.comp-row select option,
select.calc-input option {
    background-color: #1e242c;
    color: #eaf1f6;
    padding: 10px;
}

/* UPS checkbox styling */
.ups-check {
    width: 16px;
    height: 16px;
    accent-color: #4aa8b5;
    cursor: pointer;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: #1e242c;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 0;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-card.large {
    max-width: 900px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* ===== Summary styling ===== */
.summary-section {
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.summary-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.summary-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.summary-title .material-icons-outlined {
    font-size: 16px;
    opacity: 0.6;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
}

.summary-label {
    opacity: 0.6;
}

.summary-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.summary-value.ups {
    color: #5FB878;
}

.summary-value.normal {
    color: #4aa8b5;
}

.summary-value.total {
    color: #eaf1f6;
}

/* Power group list */
.pg-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
}

.pg-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.pg-item.editing .pg-label {
    display: none;
}

.pg-item .pg-input {
    display: none;
}

.pg-item.editing .pg-input {
    display: block;
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
    .rack-grid {
        grid-template-columns: 1fr;
        height: auto;
        padding: 20px;
    }
}

@media (max-width: 1400px) and (min-width: 1101px) {
    .rack-grid {
        padding: 20px 40px;
    }
}
