/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --bg-panel: #252526;
    --primary: #007acc;
    --primary-hover: #005f9e;
    --accent: #00ff88;
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    --border: #333333;
    --glass: rgba(30, 30, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);

    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffa500;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}

.glass-panel {
    background: rgba(37, 37, 38, 0.8);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
}

/* Layout */
.app-container {
    display: flex;
    height: 100%;
    width: 100%;
}

.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    flex-shrink: 0;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    position: relative;
}

/* Typography */
h1,
h2,
h3 {
    color: #fff;
    font-weight: 600;
}

h1 {
    font-size: 24px;
    letter-spacing: -0.5px;
}

h2 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--primary);
}

label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

input[type="text"],
input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    background-color: #2b2b2b;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: white;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #333;
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

.checkbox-item input {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 204, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 122, 204, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #3e3e3e;
    color: white;
}

.btn-secondary:hover {
    background: #4e4e4e;
}

.btn-block {
    width: 100%;
}

/* Table */
.table-container {
    flex: 1;
    overflow: auto;
    padding: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.data-table thead {
    background: #2b2b2b;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #2a2a2a;
    color: var(--text-main);
}

.data-table tbody tr {
    transition: background 0.15s;
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: rgba(0, 122, 204, 0.1);
}

/* Loading/Status */
.status-bar {
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    background: #181818;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--success);
}

/* Viewer specific */
.viewer-layout {
    display: flex;
    height: 100vh;
    background: black;
}

.viewer-sidebar {
    width: 240px;
    background: #1a1a1a;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
}

.thumbnail-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.thumbnail-item {
    margin-bottom: 10px;
    background: #222;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    border: 1px solid transparent;
}

.thumbnail-item:hover {
    border-color: #555;
}

.thumbnail-item.active {
    border-color: var(--primary);
    background: #2a2a2a;
}

.thumb-img {
    width: 100%;
    height: 120px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
}

.viewer-main {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

.toolbar {
    height: 50px;
    background: #2b2b2b;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 10px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
}

.viewport-grid {
    flex: 1;
    display: grid;
    background: #000;
    gap: 1px;
    overflow: hidden;
    /* Prevent scrolling of the grid itself */
    width: 100%;
    height: 100%;
}

.dicom-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    background: black;
    overflow: hidden;
    /* Important for cornerstone canvas */
}

.overlay-text {
    position: absolute;
    color: #0f0;
    /* Medical green */
    font-size: 14px;
    font-family: 'Consolas', monospace;
    font-weight: bold;
    pointer-events: none;
    text-shadow: 1px 1px 1px black;
    z-index: 10;
}

.overlay-tl {
    top: 10px;
    left: 10px;
}

.overlay-tr {
    top: 10px;
    right: 10px;
    text-align: right;
}

.overlay-bl {
    bottom: 10px;
    left: 10px;
}

.overlay-br {
    bottom: 10px;
    right: 10px;
    text-align: right;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1e1e1e;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-flex;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #2b2b2b;
    min-width: 140px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    border: 1px solid #444;
    border-radius: 6px;
    top: 100%;
    left: 0;
    flex-direction: column;
}

.dropdown:hover .dropdown-content {
    display: flex;
}

.dropdown-content .tool-btn {
    width: 100%;
    height: 40px;
    border-radius: 0;
    justify-content: flex-start;
    padding: 0 12px;
}

.dropdown-content .tool-btn:first-child {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.dropdown-content .tool-btn:last-child {
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

/* Mobile Responsiveness */
.menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 10px;
    z-index: 1000;
}

@media (max-width: 768px) {

    /* Layout Logic */
    .viewer-layout,
    .app-container {
        position: relative;
    }

    .viewer-sidebar,
    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 250px;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        background: #1a1a1a;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }

    .viewer-sidebar.active,
    .sidebar.active {
        transform: translateX(0);
    }

    /* Menu Button */
    .menu-btn {
        display: block;
        position: absolute;
        top: 5px;
        left: 5px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 4px;
    }

    /* Toolbar adjustment */
    .toolbar {
        overflow-x: auto;
        justify-content: flex-start;
        padding-left: 50px;
        /* Space for menu btn */
        white-space: nowrap;
    }

    .toolbar::-webkit-scrollbar {
        height: 4px;
    }

    .tool-btn {
        min-width: 36px;
        /* Ensure touch toggle easy */
        flex-shrink: 0;
    }

    /* Font sizes for overlays on small screens */
}

/* Global Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    backdrop-filter: blur(2px);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: #1e1e1e;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    border: 1px solid #333;
    text-align: left;
}

.modal-header {
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: bold;
    color: var(--primary);
}

.modal-body {
    font-size: 14px;
    color: #ccc;
    line-height: 1.5;
    margin-bottom: 25px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}