/* === TigerNode Styles === */

:root {
    --tn-online: #28a745;
    --tn-offline: #dc3545;
    --tn-unknown: #6c757d;
    --tn-maintenance: #fd7e14;
    --tn-bg: #f4f6f9;
    --tn-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body {
    background-color: var(--tn-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Navbar */
.navbar-brand {
    font-size: 1.25rem;
    letter-spacing: 0.5px;
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--tn-card-shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
}

/* Status indicators */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.online { background-color: var(--tn-online); box-shadow: 0 0 6px var(--tn-online); }
.status-dot.offline { background-color: var(--tn-offline); box-shadow: 0 0 6px var(--tn-offline); }
.status-dot.unknown { background-color: var(--tn-unknown); }
.status-dot.maintenance { background-color: var(--tn-maintenance); }

.status-badge {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.online { background-color: var(--tn-online); color: white; }
.status-badge.offline { background-color: var(--tn-offline); color: white; }
.status-badge.unknown { background-color: var(--tn-unknown); color: white; }
.status-badge.maintenance { background-color: var(--tn-maintenance); color: white; }

/* Building cards on dashboard */
.building-card {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.building-card:hover {
    color: inherit;
}

.building-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.building-card .stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
}

/* Progress bars */
.progress {
    height: 8px;
    border-radius: 4px;
}

/* Floor plan container */
.floorplan-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    background: white;
    border-radius: 12px;
    box-shadow: var(--tn-card-shadow);
    overflow: hidden;
}

.floorplan-wrapper img {
    display: block;
    max-width: 100%;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

/* Device icons on floor plan */
.device-marker {
    position: absolute;
    width: 36px;
    height: 36px;
    margin-left: -18px;
    margin-top: -18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    font-size: 16px;
    color: white;
    z-index: 10;
}

.device-marker:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.device-marker.online { background-color: var(--tn-online); }
.device-marker.offline { background-color: var(--tn-offline); }
.device-marker.unknown { background-color: var(--tn-unknown); }
.device-marker.maintenance { background-color: var(--tn-maintenance); }

.device-marker.dragging {
    opacity: 0.7;
    transform: scale(1.15);
    z-index: 1000;
}

/* Stack cluster marker */
.device-marker.stack-marker {
    width: 42px;
    height: 42px;
    margin-left: -21px;
    margin-top: -21px;
    font-size: 18px;
    border-width: 3px;
}

/* Stack badge */
.stack-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #333;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid white;
}

/* Device popover */
.device-popover {
    position: absolute;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    padding: 16px;
    min-width: 260px;
    z-index: 2000;
    font-size: 0.875rem;
}

.device-popover .popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.device-popover .popover-header h6 {
    margin: 0;
    font-weight: 700;
}

.device-popover .info-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}

.device-popover .info-row .label {
    color: #6c757d;
}

/* Mobile: bottom sheet popover */
@media (max-width: 768px) {
    .device-popover {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
        width: 100%;
        min-width: unset;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
        padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
        z-index: 3000;
    }

    .device-popover-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 2999;
    }
}

/* Sidebar for edit mode */
.editor-sidebar {
    position: fixed;
    right: 0;
    top: 56px;
    width: 300px;
    height: calc(100vh - 56px);
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    overflow-y: auto;
    padding: 20px;
    transition: transform 0.3s ease;
}

.editor-sidebar.collapsed {
    transform: translateX(300px);
}

.editor-sidebar .device-type-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: grab;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}

.editor-sidebar .device-type-item:hover {
    background: #f0f4ff;
    border-color: #0d6efd;
}

.editor-sidebar .device-type-item:active {
    cursor: grabbing;
}

.editor-sidebar .device-type-item .dt-icon {
    width: 28px;
    height: 28px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Edit mode body padding */
body.edit-mode main {
    margin-right: 300px;
}

/* Login page */
.login-container {
    max-width: 420px;
    margin: 80px auto;
}

.login-container .card {
    padding: 30px;
}

.login-container .brand-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-container .brand-header i {
    font-size: 3rem;
    color: #0d6efd;
}

/* Tables */
.table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    border-bottom-width: 1px;
}

/* Admin pages */
.admin-section {
    max-width: 900px;
}

/* Reports */
.report-chart-container {
    background: white;
    border-radius: 12px;
    box-shadow: var(--tn-card-shadow);
    padding: 24px;
    margin-bottom: 20px;
}

/* Breadcrumb */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1.5rem;
}

.breadcrumb-item a {
    color: #0d6efd;
    text-decoration: none;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pinging {
    animation: pulse 1s ease-in-out infinite;
}

/* Responsive */
@media (max-width: 768px) {
    .editor-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: auto;
        box-shadow: none;
        border-top: 1px solid #dee2e6;
    }

    body.edit-mode main {
        margin-right: 0;
    }

    .building-card .stat-number {
        font-size: 1.5rem;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h5 {
    margin-bottom: 8px;
}

/* Stack expansion panel */
.stack-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 500;
    border-radius: 12px;
}

.stack-panel {
    position: absolute;
    z-index: 600;
    background: white;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    padding: 14px;
    min-width: 200px;
    max-width: 360px;
    max-height: 350px;
    overflow-y: auto;
    transform-origin: top center;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.stack-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 0.9rem;
}

.stack-panel-close {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.stack-panel-close:hover {
    background: #f0f0f0;
    color: #333;
}

.stack-panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}

.stack-panel-item {
    text-align: center;
    padding: 8px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
}

.stack-panel-item:hover {
    background: #f0f4ff;
}

.stack-panel-item .device-marker {
    width: 32px;
    height: 32px;
    font-size: 14px;
    margin: 0 auto 4px;
    position: relative;
}

.stack-panel-item-name {
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80px;
    margin: 0 auto;
}

.stack-panel-item-ip {
    font-size: 0.6rem;
    color: #6c757d;
}

.stack-panel-popout {
    display: block;
    margin: 4px auto 0;
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    color: #6c757d;
    cursor: pointer;
    padding: 1px 6px;
    font-size: 0.65rem;
    transition: all 0.12s;
}

.stack-panel-popout:hover {
    background: #e9ecef;
    color: #333;
    border-color: #adb5bd;
}

/* Device form in edit mode */
.device-edit-form {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
}

.device-edit-form .form-label {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.device-edit-form .form-control,
.device-edit-form .form-select {
    font-size: 0.875rem;
}
