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

:root {
    /* Modern Dashboard Theme Variables */
    --primary-bg: #0c1520;
    --secondary-bg: #141f2d;
    --card-bg: #1a2533;
    --text-primary: #e6edf3;
    --text-secondary: #7d8590;
    --border-color: #30363d;
    --border-light: #3f464e; /* Lighter border color */
    --glass-border-color: rgba(255, 255, 255, 0.1);
    --accent-blue: #1f6feb;
    --accent-blue-hover: #388bfd;
    --accent-green: #238636;
    --accent-orange: #f08838;
    --accent-red: #da3633;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 50px; /* For pill-shaped buttons */
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --header-height: 62px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--primary-bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
}

header {
    background-color: var(--secondary-bg);
    padding: 0;
    box-shadow: var(--shadow-sm);
    height: auto;
    margin: 0;
    border-bottom: 1px solid var(--border-light);
}

.main-header-row {
    display: flex;
    align-items: flex-start;
    width: 100%;
    padding: 10px 20px;
}

.title-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.view-display {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#current-view-label {
    font-size: 1.5rem;
    margin: 0;
    padding: 0;
    font-weight: 600;
}

/* View buttons styling */
.view-button {
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 160px;
    text-align: center;
    margin-top: 5px;
}

.view-button:hover {
    background-color: var(--border-color);
}

.view-button.active {
    background-color: var(--accent-blue);
    color: white;
}

.main-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    margin-right: 20px;
}

.wifi-view-label {
    text-align: center;
    margin-bottom: 0.25rem;
    width: 100%;
}

.wifi-view-label h2 {
    font-size: 1rem;
    font-weight: normal;
    color: var(--text-primary);
    margin: 0;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-align: left;
    white-space: nowrap;
    line-height: 1.3;
}

.view-heading {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
}

.top-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    padding-bottom: 0.2rem;
    width: 100%;
    background-color: var(--secondary-bg);
    border-bottom: 1px solid var(--border-light);
    border-top: none;
    gap: 0.15rem;
    margin-top: -4px;
}

.controls-container {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    margin: 0 auto;
    gap: 0.5rem;
    max-width: 300px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 200px;
}

.label-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 1rem;
}

label {
    margin-bottom: 0;
    white-space: nowrap;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.drawing-selector label:before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml;utf8,<svg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM19 9H5V7H19V9Z' fill='%23e6edf3'/><path d='M14 17H7V15H14V17ZM17 13H7V11H17V13ZM17 9H7V7H17V9Z' fill='%23e6edf3'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.9;
}

#drawing-select {
    background-color: var(--secondary-bg);
    color: var(--text-primary);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    min-width: 140px;
    width: 140px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

select {
    padding: 0.4rem 0.75rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 100%;
    outline: none;
    box-shadow: var(--shadow-sm);
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%23e6edf3' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
    height: 36px;
}

select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.3);
}

.zoom-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    width: 120px;
    height: 30px;
    padding: 0 4px;
    margin: 0 auto;
}

main {
    flex: 1;
    display: flex;
    overflow: hidden;
    height: calc(100vh - 62px); /* Adjust based on header height */
}

.left-sidebar {
    width: 280px;
    background-color: var(--secondary-bg);
    color: var(--text-primary);
    overflow-y: auto;
    z-index: 10;
    border-right: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.sidebar-content {
    padding: 1rem 0.8rem;
    position: sticky;
    top: 0;
}

.viewer-container {
    flex: 1;
    background-color: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1; /* Explicit but low z-index */
    isolation: isolate; /* Create a new stacking context */
    /* Prevent Safari from creating a higher stacking context than intended */
    transform: translateZ(0);
}

.sidebar-table-container {
    display: block !important; /* Ensure the table container is always visible */
    padding: 1rem;
    flex-direction: column;
    gap: 1.25rem;
}

.deck-summary-table h3, .deck-detail-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Red AP OFFLINE heading */
.ap-offline {
    color: #ff3333 !important; /* Bright red color */
}

.deck-summary-table h3:before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml;utf8,<svg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z' fill='%23e6edf3'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#deck-summary, #deck-detail {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

#deck-summary th, #deck-summary td, 
#deck-detail th, #deck-detail td {
    padding: 8px 12px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    border-right: none;
    border-left: none;
}

#deck-summary th, #deck-detail th {
    background-color: var(--card-bg);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

#deck-summary tbody tr:nth-child(odd),
#deck-detail tbody tr:nth-child(odd) {
    background-color: rgba(255, 255, 255, 0.03);
}

#deck-summary tbody tr:hover,
#deck-detail tbody tr:hover {
    background-color: rgba(31, 111, 235, 0.1);
    cursor: pointer;
}

/* Red Total row */
.total-label,
.total-value {
    color: #ff3333 !important; /* Bright red color */
    font-weight: bold;
}

#deck-summary tbody tr:hover,
#deck-detail tbody tr:hover {
    position: relative;
}

#deck-summary tbody tr,
#deck-detail tbody tr {
    transition: background-color 0.2s ease;
}

#deck-summary tfoot {
    font-weight: 600;
    background-color: var(--card-bg);
}

#deck-summary tfoot td {
    border-top: 2px solid var(--border-color);
    color: var(--accent-blue);
}

.deck-detail-table-container {
    max-height: 300px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    background-color: var(--secondary-bg);
    padding: 4px;
}

.status-missing {
    background-color: rgba(218, 54, 51, 0.2) !important;
    color: var(--accent-red) !important;
    font-weight: 500;
}

.status-warning {
    background-color: rgba(240, 136, 62, 0.2) !important;
    color: var(--accent-orange) !important;
    font-weight: 500;
}

.status-normal {
    background-color: rgba(35, 134, 54, 0.2) !important;
    color: var(--accent-green) !important;
    font-weight: 500;
}

.selected-deck {
    background-color: rgba(31, 111, 235, 0.15) !important;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent-blue);
}

/* Popup styles */
.detail-popup {
    display: none;
    position: fixed;
    /* Ensure highest possible z-index */
    z-index: 2147483647 !important; /* Maximum possible z-index value */
    background-color: rgba(26, 37, 53, 0.95); /* Semi-transparent background for better visibility */
    border: 2px solid var(--accent-blue); /* Blue border for better visibility */
    border-radius: var(--radius-md);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.8); /* Stronger shadow for depth */
    padding: 0;
    max-width: 90vw; /* Allow wider popups if needed */
    width: auto;
    pointer-events: auto !important; /* CRITICAL: Enable interaction */
    max-height: 85vh; /* Slightly taller to use more screen space */
    overflow: auto !important; /* Force scrolling for tall content */
    
    /* Critical Safari/Chrome rendering fixes for z-index issues */
    transform: translateZ(0); 
    -webkit-transform: translateZ(0);
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    
    /* Additional rendering properties to force popup to top layer */
    isolation: isolate;
    contain: layout;
    will-change: transform, opacity;
    -webkit-font-smoothing: antialiased;
}

.popup-content {
    padding: 16px;
    color: var(--text-primary);
    position: relative;
}

.popup-content:before {
    content: 'Deck Details';
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

#popup-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
    width: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#popup-table th,
#popup-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

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

#popup-table tr:last-child td {
    border-bottom: none;
}

#popup-table tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

#popup-table tr:hover {
    background-color: rgba(31, 111, 235, 0.05);
}

.zoom-controls {
    display: flex;
    flex-direction: row;
    gap: 0.2rem; /* Reduce spacing between buttons */
    align-items: center;
    justify-content: center; /* Center the controls */
    background-color: transparent;
    border-radius: 0;
    border: none;
    box-shadow: none;
    width: 100%;
    height: 36px;
    padding: 0;
}

.page-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem;
    background-color: var(--secondary-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.zoom-controls button {
    background-color: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 0;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
}

/* Force override all button styling */
#zoom-in, #zoom-out, #reset-zoom {
    background-color: #00a3a3 !important; /* Teal color matching Windsurf Browser button */
    color: white !important;
    border: 1px solid #008080 !important;
    border-radius: 3px !important;
    padding: 3px 8px !important;
    font-size: 13px !important;
    font-weight: normal !important;
    font-family: system-ui, -apple-system, sans-serif !important;
    margin: 0 4px !important;
    cursor: pointer !important;
    text-align: center !important;
    min-width: 36px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

/* Override for specific styling */
#reset-zoom {
    min-width: 50px !important;
}

#zoom-in, #zoom-out {
    min-width: 36px;
    font-weight: bold;
}

.zoom-icon {
    width: 14px;
    height: 14px;
    display: block;
}

#reset-zoom {
    min-width: 50px;
}

#reset-zoom span {
    font: 12px/1 Arial, sans-serif;
    display: inline-block;
    width: 100%;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
}

#zoom-in, #zoom-out, #reset-zoom {
    min-width: 36px;
    text-align: center;
    padding: 0;
    height: 24px;
}

#reset-zoom {
    min-width: 50px;
}

.toolbar button {
    background-color: var(--accent-blue);
    color: white;
    border: none;
    border-radius: var(--radius-pill);
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar button:before, .zoom-controls button:before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#zoom-in:before {
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'/></svg>");
}

#zoom-out:before {
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M19 13H5v-2h14v2z'/></svg>");
}

#prev-page:before {
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z'/></svg>");
    margin-right: 0;
}

#next-page:before {
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z'/></svg>");
    margin-right: 0;
}

.toolbar button {
    width: 100%;
}

.toolbar button:hover, .zoom-controls button:hover {
    background-color: var(--accent-blue-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.toolbar button:active, .zoom-controls button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    background-color: var(--accent-blue);
}

#zoom-level, #page-info {
    font-weight: 500;
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-primary);
    background-color: transparent;
    padding: 0 4px;
    border: none;
    min-width: 40px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#pdf-viewer {
    width: 100%;
    height: 100%;
    overflow: auto;
    position: relative;
    z-index: 1; /* Explicitly set z-index */
}

#pdf-canvas {
    box-shadow: var(--shadow-lg);
    background-color: white;
    border-radius: var(--radius-sm);
}

footer {
    background-color: var(--secondary-bg);
    color: var(--text-secondary);
    text-align: center;
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
    main {
        flex-direction: column;
        height: auto;
    }
    
    .left-sidebar {
        width: 100%;
        max-height: 200px;
    }
    
    .sidebar-content {
        padding: 1rem;
    }
    
    .toolbar {
        flex-direction: row;
        gap: 1rem;
        justify-content: center;
    }
    
    .zoom-controls, .page-controls {
        flex: 1;
        flex-direction: row;
    }
    
    .viewer-container {
        height: auto;
        min-height: 60vh;
    }
}
