/* فونت های فارسی */
@font-face {
    font-family: 'Yekan';
    src: url('fonts/Yekan.eot');
    src: url('fonts/Yekan.eot?#iefix') format('embedded-opentype'),
         url('fonts/Yekan.woff') format('woff'),
         url('fonts/Yekan.ttf') format('truetype'),
         url('fonts/Yekan.svg#Yekan') format('svg');
    font-weight: normal;
    font-style: normal;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.main-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: white;
    border-bottom: 2px solid #3498db;
    flex-shrink: 0;
}

.header h1 {
    flex: 1;
    text-align: center;
    color: #2c3e50;
    padding: 20px;
    font-size: 1.8em;
    margin: 0;
    border-bottom: none;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.settings-btn {
    background: none;
    border: none;
    color: #3498db;
    cursor: pointer;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: all 0.3s;
    width: 44px;
    height: 44px;
    margin: 0 10px 0 0;
    flex-shrink: 0;
}

.settings-btn:hover {
    background: #ecf0f1;
    color: #2980b9;
    transform: rotate(90deg);
    transition: all 0.3s ease;
}

.content-wrapper {
    display: flex;
    flex: 1;
    gap: 10px;
    padding: 10px;
    overflow: hidden;
}

/* پنل چپ - ورودی‌ها */
.left-panel {
    width: 300px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    flex-shrink: 0;
}

/* پنل وسط - نقشه */
.center-panel {
    flex: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* پنل راست - نتایج */
.right-panel {
    width: 350px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    flex-shrink: 0;
}

h2 {
    color: #34495e;
    margin-bottom: 15px;
    border-bottom: 2px solid #3498db;
    padding: 15px;
    padding-bottom: 10px;
    font-size: 1.2em;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.input-section {
    padding: 15px;
}

.input-group {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-weight: bold;
    color: #2c3e50;
    font-size: 0.9em;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.input-group input[type="number"], .input-group select {
    padding: 8px 10px;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    font-size: 0.9em;
    transition: border-color 0.3s;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.input-group input[type="text"], .input-group input[type="tel"], .input-group input[type="file"] {
    padding: 8px 10px;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    font-size: 0.9em;
    transition: border-color 0.3s;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.input-group input[type="number"]:focus, .input-group select:focus, .input-group input[type="text"]:focus, .input-group input[type="tel"]:focus, .input-group input[type="file"]:focus {
    outline: none;
    border-color: #3498db;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    color: #555;
    font-size: 0.85em;
    cursor: default;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #e74c3c;
    flex-shrink: 0;
}

/* چک‌باکس container - فقط خود چک‌باکس کلیک‌پذیر است */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    color: #555;
    font-size: 0.85em;
    user-select: none;
}

.checkbox-container input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #e74c3c;
    flex-shrink: 0;
}

.checkbox-container span {
    cursor: default;
    pointer-events: none;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

button {
    background: #3498db;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: background 0.3s;
    width: 100%;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

button:hover {
    background: #2980b9;
}

button.reset-btn {
    background: #95a5a6;
}

button.reset-btn:hover {
    background: #7f8c8d;
}

button.export-btn {
    background: #27ae60;
}

button.export-btn:hover {
    background: #229954;
}

button.exit-blur-btn,
#exitBlurBtn {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    font-weight: bold;
    transition: all 0.3s ease;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
}

button.exit-blur-btn:hover,
#exitBlurBtn:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button.exit-blur-btn:active,
#exitBlurBtn:active {
    transform: scale(0.98);
}

.map-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 15px;
    gap: 10px;
    position: relative;
}

.scale-info {
    text-align: center;
    font-weight: bold;
    color: #7f8c8d;
    font-size: 0.85em;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
}

.scale-info p {
    margin: 0;
}

.scale-info span {
    color: #e74c3c;
    display: block;
    margin-top: 5px;
}

#svgContainer {
    flex: 1;
    border: 1px solid #95a5a6;
    background: #fafafa;
    cursor: grab;
    overflow: hidden;
    border-radius: 5px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#svgContainer svg {
    width: 100%;
    height: 100%;
}

#svgContainer:active {
    cursor: grabbing;
}

.calculations-section {
    padding: 15px;
}

#calculations {
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
    font-size: 0.85em;
    max-height: 70vh;
    overflow-y: auto;
}

.calculation-item {
    margin-bottom: 8px;
    padding: 5px;
    border-bottom: 1px dashed #ecf0f1;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.calculation-item:last-child {
    border-bottom: none;
}

.dimension-text {
    font-size: 16px;
    fill: #2c3e50;
    font-weight: bold;
}

/* فونت سایز لیبل مربوط به ابعاد کابین */
.cabin-info-label {
    font-size: 22px !important;
}

.dimension-line {
    stroke: #7f8c8d;
    stroke-width: 1;
    stroke-dasharray: 5,3;
}

.diagonal-line {
    stroke: #9b59b6;
    stroke-width: 1.5;
    stroke-dasharray: 5,3;
}

.arrow-head {
    fill: #7f8c8d;
}

.diagonal-arrow {
    fill: #9b59b6;
}

/* scrollbar styling */
.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar,
#calculations::-webkit-scrollbar,
.map-tabs::-webkit-scrollbar,
.content-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 4px;
}

.left-panel::-webkit-scrollbar-track,
.right-panel::-webkit-scrollbar-track,
#calculations::-webkit-scrollbar-track,
.map-tabs::-webkit-scrollbar-track,
.content-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.left-panel::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb,
#calculations::-webkit-scrollbar-thumb,
.map-tabs::-webkit-scrollbar-thumb,
.content-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.left-panel::-webkit-scrollbar-thumb:hover,
.right-panel::-webkit-scrollbar-thumb:hover,
#calculations::-webkit-scrollbar-thumb:hover,
.map-tabs::-webkit-scrollbar-thumb:hover,
.content-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Settings Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 800px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 2px solid #ecf0f1;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
    border-bottom: none;
    padding: 0;
    font-size: 1.5em;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #7f8c8d;
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.close-btn:hover {
    color: #e74c3c;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #ecf0f1;
    flex-shrink: 0;
    justify-content: flex-end;
}

.modal-footer button {
    padding: 10px 20px;
    min-width: 120px;
}

.reset-settings-btn {
    background: #e74c3c;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.reset-settings-btn:hover {
    background: #c0392b;
}

.close-settings-btn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.close-settings-btn:hover {
    background: #7f8c8d;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    border-bottom: 2px solid #ecf0f1;
    margin-bottom: 20px;
    gap: 0;
}

.settings-tab-btn {
    background: #f8f9fa;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-weight: bold;
    color: #7f8c8d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    margin-bottom: -2px;
    font-size: 0.95em;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.settings-tab-btn:hover {
    background: #ecf0f1;
    color: #34495e;
}

.settings-tab-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: white;
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

.settings-tabs-content {
    display: flex;
    flex-direction: column;
}

.settings-category {
    margin-bottom: 30px;
}

.settings-category-title {
    font-size: 1.1em;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    flex-wrap: wrap;
}

.settings-item-label {
    flex: 0 1 200px;
    font-weight: bold;
    color: #34495e;
    font-size: 0.9em;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.settings-item-input {
    flex: 0 1 150px;
    padding: 8px 10px;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    font-size: 0.9em;
    transition: border-color 0.3s;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.settings-item-input:focus {
    outline: none;
    border-color: #3498db;
    background: #ecf0f1;
}

.settings-item-description {
    flex: 0 1 100%;
    font-size: 0.8em;
    color: #95a5a6;
    padding-left: 210px;
    margin-top: -8px;
}

.settings-item-unit {
    color: #7f8c8d;
    font-size: 0.85em;
    font-weight: bold;
}

/* Loading Spinner Styles */
.loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.welcome-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 40px;
    text-align: center;
}

.welcome-logo {
    max-width: 200px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.welcome-text {
    font-size: 18px;
    color: #34495e;
    line-height: 1.8;
    max-width: 500px;
    font-weight: 500;
}

.loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.loading-spinner.fade-out {
    animation: fadeOut 0.8s ease-out forwards;
}

/* Global Preview Overlay - Covers entire map-container for silent calculations */
.global-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
}

.global-preview-overlay.fade-out {
    animation: fadeOut 0.8s ease-out forwards;
}

/* Global Loading Overlay - Covers entire map-container */
.global-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
}

.global-loading-overlay.fade-out {
    animation: fadeOut 0.8s ease-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        backdrop-filter: blur(2px);
    }
    to {
        opacity: 0;
        backdrop-filter: blur(0px);
        pointer-events: none;
    }
}

.spinner-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #ecf0f1;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.spinner-text {
    font-size: 16px;
    color: #2c3e50;
    font-weight: 500;
    margin: 0;
}

.countdown {
    font-size: 18px;
    color: #3498db;
    font-weight: bold;
    padding: 10px 20px;
    background: #ecf0f1;
    border-radius: 5px;
    min-width: 100px;
}

#countdownTimer {
    font-size: 24px;
    color: #e74c3c;
    font-weight: bold;
}

/* Map Tabs */
.map-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
    overflow-x: auto;
}

.map-tab-btn {
    padding: 10px 20px;
    background: #ecf0f1;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #7f8c8d;
    transition: all 0.3s ease;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    white-space: nowrap;
    flex-shrink: 0;
}

.map-tab-btn:hover {
    background: #d5dbdb;
}

.map-tab-btn.active {
    background: white;
    border-bottom-color: #3498db;
    color: #2c3e50;
    font-weight: bold;
}

.map-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.map-tab-content.active {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Components Section */
.components-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 15px;
}

.component-group {
    border: 1px solid #bdc3c7;
    padding: 15px;
    border-radius: 5px;
    background: #f8f9fa;
}

.component-group h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.component-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.component-item label {
    flex: 1;
    color: #34495e;
    font-weight: 500;
    text-align: right;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.component-item input {
    flex: 0 0 150px;
    padding: 8px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.component-preview {
    margin-top: 20px;
    padding: 15px;
    background: white;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.components-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.component-selector-area {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #bdc3c7;
}

.component-selector-area label {
    font-weight: 500;
    color: #34495e;
    margin: 0;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.component-selector-area select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.component-preview-area {
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    min-height: 500px;
    position: relative;
    overflow: hidden;
    touch-action: none;
}

.component-preview-area #componentPreview {
    margin: 0;
    padding: 0;
}

.component-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.component-controls button {
    padding: 10px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.3s;
}

.component-controls button:hover {
    background: #2980b9;
}

.component-controls button:active {
    background: #1a5c7a;
}

.back-view-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.back-view-controls button {
    padding: 10px 20px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s;
}

.back-view-controls button:hover {
    background: #229954;
}

.back-view-controls button:active {
    background: #1a5e3f;
}

/* Legend styles for dimension labels */
#svgContainer {
    width: 100%;
    height: 100%;
}

#dimensionLegend {
    display: none;
}

.legend-section {
    padding: 10px 0;
}

.legend-section h4 {
    margin-bottom: 10px;
    font-size: 14px;
    color: #2c3e50;
}

.legend-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.legend-table tr {
    border-bottom: 1px solid #bdc3c7;
}

.legend-table tr:last-child {
    border-bottom: none;
}

.legend-table td {
    padding: 6px 8px;
    text-align: right;
}

.legend-letter {
    width: 35px;
    background: #3498db;
    color: white;
    font-weight: bold;
    text-align: center;
    border-radius: 3px;
}

.legend-label {
    padding-left: 12px;
    color: #34495e;
}

.map-controls {
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 20px;
    align-items: center;
}

.map-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.map-controls input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.map-controls input[type="checkbox"]:checked {
    accent-color: #3498db;
}

/* حذف spinner (فلش‌های بالا/پایین) از input های number */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* دکمه تمام صفحه */
.fullscreen-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Yekan', Arial, sans-serif;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.fullscreen-btn:hover {
    background-color: #2980b9;
}

.fullscreen-btn:active {
    background-color: #1f618d;
}

/* حالت تمام صفحه - برای تمام تب‌ها */
.fullscreen-active {
    position: relative;
}

/* عام‌سازی برای تمام SVG containers در حالت fullscreen */
.fullscreen-active #svgContainer,
.fullscreen-active #backViewPreview,
.fullscreen-active #sideViewPreview,
.fullscreen-active #steelRoofViewPreview,
.fullscreen-active #falseCeilingViewPreview,
.fullscreen-active #steelFloorViewPreview,
.fullscreen-active #advancedSvgContainer,
.fullscreen-active #simpleSvgContainer,
.fullscreen-active #isometricContainer,
.fullscreen-active .component-preview-area {
    position: fixed !important;
    top: 60px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 60px) !important;
    z-index: 9999 !important;
    background: white !important;
    overflow: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* تضمین SVG ایزومتریک تمام فضا را استفاده کند */
.fullscreen-active #isometricContainer svg,
.fullscreen-active #isometricContainer #isometricSvg {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
}

/* تنظیمات کنترل‌های نقشه در حالت fullscreen */
.fullscreen-active .map-controls,
.fullscreen-active .back-view-controls {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #2c3e50;
    padding: 10px 20px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.fullscreen-active .fullscreen-btn {
    background-color: #e74c3c;
    order: -1;
}


.fullscreen-active .fullscreen-btn:hover {
    background-color: #c0392b;
}

.fullscreen-active label {
    display: none;
}

.fullscreen-active .fullscreen-btn svg {
    transform: none;
}

/* تب ایزومتریک - پنهان کردن عنوان و توضیحات در fullscreen */
#mapTab-isometric.fullscreen-active h2,
#mapTab-isometric.fullscreen-active p {
    display: none;
}

/* ===== History Modal Styles ===== */
.header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.history-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 5px;
    transition: background 0.3s, color 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
}

.history-btn:hover {
    background: #ecf0f1;
}

.history-btn svg {
    width: 20px;
    height: 20px;
    fill: #2c3e50;
    flex-shrink: 0;
}

.history-btn span {
    white-space: nowrap;
}

#historyModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#historyModal.show {
    display: flex;
}

.history-content {
    max-height: 400px;
    overflow-y: auto;
}

.no-history {
    text-align: center;
    color: #7f8c8d;
    padding: 40px 20px;
    font-style: italic;
}

.history-records {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-record {
    border: 1px solid #ecf0f1;
    border-radius: 5px;
    padding: 15px;
    background: #f9f9f9;
    transition: background 0.3s;
}

.history-record:hover {
    background: #f0f8ff;
    border-color: #3498db;
}

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

.record-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.1em;
    flex: 1;
}

.record-time {
    color: #7f8c8d;
    font-size: 0.9em;
    white-space: nowrap;
    margin-right: 10px;
}

.record-details {
    padding: 8px 0;
    margin-bottom: 10px;
}

.record-details p {
    margin: 5px 0;
    font-size: 0.95em;
    color: #34495e;
}

.record-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-details,
.btn-delete {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s, color 0.3s;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.btn-details {
    background: #3498db;
    color: white;
}

.btn-details:hover {
    background: #2980b9;
}

.btn-delete {
    background: #e74c3c;
    color: white;
}

.btn-delete:hover {
    background: #c0392b;
}

.clear-history-btn {
    background: #e74c3c;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.clear-history-btn:hover {
    background: #c0392b;
}

.close-history-btn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.close-history-btn:hover {
    background: #7f8c8d;
}

/* ===== RESPONSIVE DESIGN FOR MOBILE & TABLETS ===== */

/* Extra Small Screens (Mobile Phones - 320px to 480px) */
@media screen and (max-width: 600px) {
    /* Hide horizontal scrolling */
    html, body {
        overflow-x: hidden;
    }

    .main-container {
        height: 100vh;
    }

    /* Header adjustments */
    .header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 5px;
        border-bottom: 1px solid #3498db;
    }

    .header h1 {
        font-size: 1.2em;
        padding: 10px 5px;
        margin: 0;
    }

    .header-buttons {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        justify-content: center;
    }

    .history-btn, .settings-btn {
        width: 40px;
        height: 40px;
        padding: 8px;
        margin: 0 !important;
    }

    .history-btn svg, .settings-btn svg {
        width: 18px;
        height: 18px;
    }

    #requestCounter {
        width: 100%;
        justify-content: center;
        margin: 0 !important;
        padding: 8px 10px !important;
        font-size: 0.85em !important;
    }

    /* Content wrapper - single column */
    .content-wrapper {
        flex-direction: column;
        gap: 5px;
        padding: 5px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Panels - full width */
    .left-panel {
        width: 100%;
        max-height: 300px;
        order: 2;
        flex-shrink: 0;
        overflow-y: auto;
    }

    .right-panel {
        width: 100%;
        max-height: 300px;
        order: 3;
        flex-shrink: 0;
        overflow-y: auto;
    }

    .center-panel {
        flex: 0 0 auto;
        min-height: 400px;
        order: 1;
        flex-shrink: 0;
        overflow-y: auto;
    }

    /* تب‌های نقشه در موبایل */
    .map-tabs {
        max-height: 50px;
        overflow-y: hidden;
    }

    .map-tab-btn {
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
        min-width: 140px;
        width: 140px;
    }

    /* بخش محاسبات scroll‌پذیر */
    .calculations-section {
        flex: 0 0 auto;
        overflow-y: auto;
        max-height: 100%;
        padding: 15px;
    }

    #calculations {
        max-height: none;
        padding: 0;
        font-size: 0.75em;
        overflow-y: visible;
    }

    /* Input section adjustments */
    .input-section {
        padding: 10px;
        overflow-y: visible;
    }

    .input-group {
        margin-bottom: 10px;
    }

    .input-group label {
        font-size: 0.85em;
    }

    .input-group input[type="number"], 
    .input-group select,
    .input-group input[type="text"],
    .input-group input[type="tel"],
    .input-group input[type="file"] {
        padding: 10px 8px;
        font-size: 0.95em;
        width: 100%;
    }

    /* Buttons */
    button {
        padding: 12px 10px;
        font-size: 0.85em;
        width: 100%;
    }

    .button-group {
        margin-top: 10px;
    }

    /* Calculations */
    #calculations {
        max-height: 150px;
        font-size: 0.75em;
        padding: 10px;
    }

    .calculation-item {
        margin-bottom: 5px;
    }

    /* Map container adjustments */
    .map-container {
        padding: 10px;
        gap: 8px;
    }

    /* SVG Container - بهتر شده برای موبایل */
    #svgContainer {
        min-height: 200px;
        flex: 1;
    }

    .scale-info {
        padding: 8px;
        font-size: 0.75em;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
        height: 85vh;
        max-width: none;
        border-radius: 8px;
    }

    .modal-header h2 {
        font-size: 1.2em;
    }

    .modal-body {
        padding: 15px;
        font-size: 0.9em;
    }

    /* Settings tabs */
    .settings-tabs {
        flex-wrap: wrap;
        margin-bottom: 15px;
    }

    .settings-tab-btn {
        padding: 10px 12px;
        font-size: 0.8em;
        flex: 1;
        min-width: 80px;
    }

    /* Settings items */
    .settings-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .settings-item-label {
        flex: 0 1 100%;
        margin-bottom: 8px;
    }

    .settings-item-input {
        flex: 1;
        width: 100%;
    }

    .settings-item-description {
        padding-left: 0;
        margin-top: 5px;
    }

    /* Map controls */
    .map-controls {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .map-controls label {
        font-size: 0.85em;
    }

    /* SVG container */
    #svgContainer {
        min-height: 250px;
    }

    /* Components section */
    .components-section {
        gap: 15px;
        padding: 10px;
    }

    .component-group {
        padding: 10px;
    }

    .component-group h3 {
        font-size: 1em;
        margin-bottom: 10px;
    }

    .component-selector-area {
        flex-direction: column;
    }

    .component-selector-area select {
        width: 100%;
    }

    .component-preview-area {
        min-height: 300px;
        margin-bottom: 15px;
    }

    /* History modal */
    .history-content {
        max-height: 300px;
    }

    .history-record {
        padding: 12px;
        border-radius: 5px;
    }

    .record-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .record-time {
        margin-right: 0;
        margin-top: 5px;
    }

    .record-actions {
        width: 100%;
        margin-top: 10px;
    }

    .btn-details, .btn-delete {
        flex: 1;
        padding: 8px 10px;
        font-size: 0.8em;
    }

    /* Details modal */
    .details-content {
        padding: 15px;
        max-height: 500px;
    }

    .details-grid {
        grid-template-columns: 1fr;
    }

    .detail-item {
        padding: 10px;
    }

    .detail-label {
        font-size: 0.9em;
    }

    .detail-value {
        font-size: 0.85em;
    }

    /* Receipt images */
    .receipt-thumbnail,
    .receipt-full-image {
        max-height: 120px;
    }

    /* Fullscreen mode adjustments */
    .fullscreen-active .map-controls,
    .fullscreen-active .back-view-controls {
        height: 50px;
        padding: 8px 10px;
    }

    .fullscreen-active .fullscreen-btn {
        padding: 8px 12px;
        font-size: 0.75em;
    }

    .fullscreen-active .fullscreen-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* Small Screens / Tablets (600px to 768px) */
@media screen and (max-width: 768px) and (min-width: 601px) {
    .header h1 {
        font-size: 1.3em;
        padding: 15px 10px;
    }

    .header-buttons {
        gap: 8px;
    }

    .content-wrapper {
        flex-direction: column;
        gap: 8px;
    }

    .left-panel, .right-panel {
        width: 100%;
        max-height: 280px;
    }

    .center-panel {
        flex: 1;
        min-height: 350px;
    }

    .input-section {
        padding: 12px;
    }

    .input-group input[type="number"],
    .input-group select,
    .input-group input[type="text"],
    .input-group input[type="tel"],
    .input-group input[type="file"] {
        width: 100%;
    }

    button {
        padding: 11px 12px;
        font-size: 0.9em;
    }

    .modal-content {
        width: 90%;
        height: 80vh;
    }

    #calculations {
        max-height: 180px;
        font-size: 0.8em;
    }

    .settings-item {
        flex-direction: column;
    }

    .settings-item-label {
        width: 100%;
        margin-bottom: 8px;
    }

    .settings-item-input {
        width: 100%;
    }

    .component-preview-area {
        min-height: 350px;
    }
}

/* Medium Screens / Large Tablets (768px to 1024px) */
@media screen and (max-width: 1024px) and (min-width: 769px) {
    .header {
        padding: 15px 15px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .content-wrapper {
        gap: 8px;
    }

    .left-panel {
        width: 250px;
    }

    .right-panel {
        width: 280px;
    }

    .input-group label {
        font-size: 0.9em;
    }

    .button-group {
        gap: 8px;
    }

    .settings-item {
        flex-wrap: wrap;
    }

    .settings-item-label {
        flex: 0 1 150px;
    }

    .settings-item-input {
        flex: 0 1 150px;
    }

    .component-preview-area {
        min-height: 400px;
    }

    .modal-content {
        width: 85%;
        height: 80vh;
    }
}

/* Large Screens (Desktop - 1025px and above) */
@media screen and (min-width: 1025px) {
    /* Content wrapper - 3 column layout */
    .content-wrapper {
        flex-direction: row;
        gap: 10px;
        padding: 10px;
        overflow: hidden;
    }

    .left-panel {
        width: 300px;
        max-height: none;
        order: 0;
        flex-shrink: 0;
    }

    .center-panel {
        flex: 1;
        order: 0;
        flex-shrink: 0;
    }

    .right-panel {
        width: 350px;
        max-height: none;
        order: 0;
        flex-shrink: 0;
    }

    /* Map tabs - display all tabs */
    .map-tabs {
        max-height: none;
        overflow-y: visible;
    }

    .map-tab-btn {
        padding: 10px 20px;
        font-size: 14px;
        min-width: auto;
        width: auto;
    }

    /* Calculations section */
    .calculations-section {
        padding: 15px;
    }

    #calculations {
        max-height: 70vh;
        padding: 15px;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .modal-content {
        width: 90%;
        max-width: 800px;
        height: 80vh;
    }
}

/* ===== HAMBURGER MENU FOR MOBILE ===== */

.hamburger-menu {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    order: 1;
}

.hamburger-menu span {
    width: 24px;
    height: 2px;
    background: #2c3e50;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Mobile menu overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 999;
}

.mobile-menu-overlay.show {
    display: block;
}

.mobile-menu {
    position: fixed;
    right: -300px;
    top: 0;
    width: 250px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
    transition: right 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
    padding-top: 70px;
    display: flex;
    flex-direction: column;
}

.mobile-menu.show {
    right: 0;
}

.mobile-menu-item {
    padding: 15px 20px;
    border-bottom: 1px solid #ecf0f1;
    background: none;
    border: none;
    cursor: pointer;
    text-align: right;
    color: #2c3e50;
    font-size: 0.95em;
    font-weight: 500;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background 0.3s;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
}

.mobile-menu-item:hover {
    background: #f8f9fa;
}

.mobile-menu-item svg {
    width: 20px;
    height: 20px;
}

/* Show hamburger on mobile */
@media screen and (max-width: 600px) {
    .hamburger-menu {
        display: flex;
    }

    .header-buttons {
        display: none;
    }

    #requestCounter {
        position: fixed;
        top: 10px;
        left: 10px;
        margin: 0 !important;
        z-index: 100;
        width: auto;
        display: none !important;
    }

    #requestCounter.show {
        display: flex !important;
    }
}
/* ===== Details Modal Styles ===== */
.details-content {
    padding: 20px;
    max-height: 600px;
    overflow-y: auto;
}

.details-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #3498db;
}

.details-header h2 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1.5em;
}

.details-date {
    color: #7f8c8d;
    font-size: 0.9em;
    margin: 0;
}

.details-section {
    margin-bottom: 25px;
}

.details-section h3 {
    color: #34495e;
    font-size: 1.2em;
    margin: 0 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #ecf0f1;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #3498db;
}

.detail-label {
    color: #2c3e50;
    font-weight: bold;
    font-size: 0.95em;
    margin-bottom: 5px;
}

.detail-value {
    color: #555;
    font-size: 0.95em;
    word-break: break-word;
}

/* Receipt Image Styles */
.receipt-thumbnail {
    max-width: 100%;
    max-height: 150px;
    border-radius: 4px;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: transform 0.3s;
}

.receipt-thumbnail:hover {
    transform: scale(1.05);
}

.receipt-full-image {
    max-width: 100%;
    max-height: 500px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.record-receipt {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ecf0f1;
}

.close-details-btn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
    font-family: 'Yekan', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.close-details-btn:hover {
    background: #7f8c8d;
}

/* ===== Restricted Mode Styles ===== */

/* Blur dimension labels on SVG diagrams */
body.restricted-mode .dimension-label {
    filter: blur(3px) !important;
    opacity: 0.6 !important;
}

/* Blur legend values in the legend section */
body.restricted-mode .legend-value {
    filter: blur(2px) !important;
    opacity: 0.5 !important;
}

/* Blur legend container (rectangle background) */
body.restricted-mode .legend-container {
    filter: blur(2px) !important;
    opacity: 0.7 !important;
}

/* Blur calculations panel */
body.restricted-mode .calculations-section,
body.restricted-mode #calculationsPanel {
    filter: blur(4px) !important;
    opacity: 0.7 !important;
    pointer-events: none !important;
}

/* Blur all content inside calculations panel */
body.restricted-mode .calculations-section h2,
body.restricted-mode .calculations-section .calculation-section,
body.restricted-mode .calculations-section .calculation-item,
body.restricted-mode #calculations > * {
    filter: blur(3px) !important;
}

/* Blur capacity review section labels */
body.restricted-mode #capacityReviewSection {
    filter: blur(3px) !important;
    opacity: 0.6 !important;
}

/* Blur SVG text containing "کابین جدید" (new cabin) labels */
body.restricted-mode text[data-cabin-type="new-cabin"],
body.restricted-mode .new-cabin-label {
    filter: blur(3px) !important;
    opacity: 0.6 !important;
}

/* Protected blur elements - cannot be bypassed */
#calculationsPanel[data-blur-protected="true"],
.blur-formula-section[data-blur-protected="true"],
.blur-protected {
    filter: blur(4px) !important;
    opacity: 0.7 !important;
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.blur-formula-section {
    filter: blur(3px) !important;
    opacity: 0.6 !important;
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Extra layer - make sure no child elements can override */
[data-blur-protected="true"] * {
    filter: inherit !important;
    opacity: inherit !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    pointer-events: none !important;
}

/* SVG text elements blur for all view tabs */
svg text[data-blur-protected="true"] {
    filter: blur(2px) !important;
    opacity: 0.65 !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* 🔓 Override blur - for disabling blur effect */
.blur-removed,
.blur-removed[data-blur-protected="true"],
.blur-removed.blur-protected,
.blur-removed.blur-formula-section {
    filter: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    user-select: auto !important;
    -webkit-user-select: auto !important;
    -moz-user-select: auto !important;
    -ms-user-select: auto !important;
}

/* 🔓 Override restricted-mode blur when admin-mode is active */
body.admin-mode .dimension-label,
body.admin-mode .legend-value,
body.admin-mode .legend-container,
body.admin-mode .calculations-section,
body.admin-mode #calculationsPanel,
body.admin-mode .new-cabin-label,
body.admin-mode text[data-cabin-type="new-cabin"] {
    filter: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}