:root {
    --bg-color: #121212;
    --panel-bg: rgba(30, 30, 30, 0.85);
    --panel-border: rgba(255, 255, 255, 0.15);
    --text-color: #f0f0f0;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-bg: #2a2a2a;
    --secondary-hover: #3a3a3a;
    --active-color: #10b981;
}

body.light-theme {
    --bg-color: #f0f2f5;
    --panel-bg: rgba(255, 255, 255, 0.9);
    --panel-border: rgba(0, 0, 0, 0.1);
    --text-color: #222;
    --secondary-bg: #e5e7eb;
    --secondary-hover: #d1d5db;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#viewer-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ui-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Panelin ekran yüksekliğini aşmaması için */
    max-height: calc(100vh - 40px);
    align-items: flex-start;
}

#ui-container.menu-hidden {
    transform: translateX(calc(-100% - 20px));
}

#left-sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Ekrana sığmayan içerik için scroll */
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    /* Scrollbar stilini incelti */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
    padding-right: 4px;
}

.toggle-menu-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: -30px;
    width: 30px;
    height: 30px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    z-index: 11;
    transition: background-color 0.2s;
}

.toggle-menu-btn:hover {
    background-color: var(--primary-hover);
}

/* UI Elements need to receive pointer events */
.panel {
    pointer-events: auto;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.header-panel {
    align-self: flex-start;
}

.header-panel h1 {
    font-size: 24px;
    margin-bottom: 5px;
    color: var(--text-color);
}

.header-panel p {
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.7;
}

.control-panel {
    align-self: flex-start;
    width: 320px;
}

.btn {
    display: inline-block;
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    text-align: center;
    font-size: 14px;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
}

.secondary-btn {
    background-color: var(--secondary-bg);
    color: var(--text-color);
    border: 1px solid var(--panel-border);
    padding: 6px 12px;
    font-size: 12px;
}

.secondary-btn:hover {
    background-color: var(--secondary-hover);
}

.header-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.divider {
    height: 1px;
    background-color: var(--panel-border);
    margin: 20px 0;
}

.control-group h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    color: #bbb;
}

.toggle-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.toggle-btn {
    flex: 1;
    background-color: var(--secondary-bg);
    color: var(--text-color);
    border: 1px solid var(--panel-border);
}

.toggle-btn:hover {
    background-color: #333;
}

.toggle-btn.active {
    background-color: var(--active-color);
    color: white;
    border-color: var(--active-color);
}

.hidden {
    display: none !important;
}

.instructions {
    background-color: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
}

#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 24px;
    font-weight: 300;
    z-index: 5;
    pointer-events: none;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

#property-panel {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 320px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 10px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 20px;
    cursor: pointer;
}

.property-content {
    overflow-y: auto;
    font-size: 13px;
    padding-right: 5px;
}

.property-item {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--panel-border);
}

.property-name {
    font-weight: bold;
    color: var(--primary-color);
}

.property-value {
    display: block;
    margin-top: 3px;
    word-break: break-all;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Ayar satırı yardımcıları ─────────────────────────────────────────── */
.settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.settings-row label {
    white-space: nowrap;
    opacity: 0.85;
}

.color-pick {
    width: 36px;
    height: 24px;
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    cursor: pointer;
    background: none;
    padding: 1px;
}

.range-val {
    min-width: 30px;
    text-align: right;
    font-size: 11px;
    opacity: 0.75;
    font-variant-numeric: tabular-nums;
}

/* Kaydırıcı (range input) genel stili */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--secondary-bg);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    cursor: pointer;
}

/* ── Yardım Modalı ────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-box {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    overflow: hidden;
}

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

.modal-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-color);
}

.modal-tabs {
    display: flex;
    gap: 0;
    padding: 0 16px;
    border-bottom: 1px solid var(--panel-border);
    flex-shrink: 0;
    overflow-x: auto;
}

.modal-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-color);
    opacity: 0.6;
    cursor: pointer;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: opacity 0.2s, border-color 0.2s;
}

.modal-tab.active {
    opacity: 1;
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
}

.modal-tab:hover { opacity: 0.9; }

.modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.help-section {
    margin-bottom: 18px;
}

.help-section h3 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.help-section p {
    font-size: 13px;
    line-height: 1.65;
    opacity: 0.88;
}

.shortcut-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 5px 12px;
    font-size: 12.5px;
    align-items: center;
}

.key {
    background: var(--secondary-bg);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    padding: 3px 8px;
    font-family: 'Courier New', monospace;
    font-size: 11.5px;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 2px 0 rgba(0,0,0,0.4);
}

.help-list {
    padding-left: 18px;
    font-size: 13px;
    line-height: 1.8;
    opacity: 0.88;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* ── Ölçüm Hint Barı ─────────────────────────────────────────────────── */
.measure-hint {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15,15,20,0.9);
    border: 1px solid rgba(255,255,0,0.4);
    border-radius: 24px;
    padding: 8px 20px;
    font-size: 13px;
    color: #fff;
    z-index: 50;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

