:root {
    --primary-color: #4CAF50; /* سبز */
    --secondary-color: #2196F3; /* آبی */
    --background-color: #2c3e50; /* خاکستری تیره */
    --text-color: #ecf0f1; /* سفید مایل به خاکستری */
    --danger-color: #e74c3c; /* قرمز */
    --border-radius: 15px;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden; /* جلوگیری از اسکرول */
    direction: rtl; /* جهت راست به چپ */
    text-align: center;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 25px;
    padding: 20px;
    background-color: #34495e; /* کمی روشن‌تر از پس‌زمینه */
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    width: 90%;
    max-width: 500px;
}

.inclinometer-display {
    width: 250px;
    height: 250px;
    border: 8px solid var(--primary-color);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(var(--primary-color), 0.7);
    overflow: hidden;
    background: linear-gradient(45deg, #444, #333);
}

.angle-text {
    font-size: 3.5em;
    font-weight: bold;
    color: var(--text-color);
    text-shadow: 0 0 15px rgba(var(--text-color), 0.8);
    position: relative;
    z-index: 2; /* بالاتر از gradient */
}

.direction-indicator {
    position: absolute;
    bottom: 20px;
    font-size: 2em;
    color: rgba(var(--text-color), 0.7);
    opacity: 0; /* ابتدا پنهان */
    transition: opacity 0.3s ease-in-out;
    z-index: 2;
}

.direction-indicator.active {
    opacity: 1;
}

.direction-indicator .up {
    transform: rotate(0deg);
    transition: transform 0.3s ease-in-out;
}

.direction-indicator .down {
    transform: rotate(180deg);
    transition: transform 0.3s ease-in-out;
}

/* افکت موجی برای نمایش شیب */
.inclinometer-display::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, var(--primary-color) 0%, var(--secondary-color) 100%);
    transform-origin: center top;
    transform: rotate(0deg) translateY(0%); /* کنترل با JS */
    transition: transform 0.1s linear; /* انیمیشن نرم‌تر */
    border-radius: 50%;
    z-index: 1;
}

/* تراز سنج افقی (مثل حباب تراز) */
.level-indicator-horizontal {
    width: 200px;
    height: 20px;
    background-color: #555;
    border-radius: 10px;
    position: relative;
    margin-top: 20px;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.level-indicator-horizontal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 100%;
    background-color: var(--secondary-color);
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(var(--secondary-color), 0.7);
    transition: transform 0.1s linear;
}

/* تراز سنج عمودی (مثل حباب تراز) */
.level-indicator-vertical {
    height: 200px;
    width: 20px;
    background-color: #555;
    border-radius: 10px;
    position: relative;
    margin-right: 20px; /* برای قرار گرفتن در کنار */
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.level-indicator-vertical::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 30px;
    width: 100%;
    background-color: var(--secondary-color);
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(var(--secondary-color), 0.7);
    transition: transform 0.1s linear;
}


.button-container {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

button {
    padding: 12px 25px;
    font-size: 1.1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: var(--primary-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 15px rgba(var(--primary-color), 0.4);
}

button:hover {
    background-color: #5cb85c;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--primary-color), 0.6);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(var(--primary-color), 0.3);
}

button#calibrateBtn {
    background-color: var(--secondary-color);
    box-shadow: 0 4px 15px rgba(var(--secondary-color), 0.4);
}

button#calibrateBtn:hover {
    background-color: #4da6ff;
    box-shadow: 0 6px 20px rgba(var(--secondary-color), 0.6);
}

.instructions {
    margin-top: 20px;
    font-size: 0.9em;
    color: rgba(var(--text-color), 0.8);
    line-height: 1.6;
}

/* Media Queries برای واکنش‌گرایی */
@media (max-width: 600px) {
    .inclinometer-display {
        width: 200px;
        height: 200px;
        border-width: 6px;
    }
    .angle-text {
        font-size: 3em;
    }
    .direction-indicator {
        font-size: 1.8em;
        bottom: 15px;
    }
    button {
        padding: 10px 20px;
        font-size: 1em;
    }
    .button-container {
        flex-direction: column; /* دکمه‌ها زیر هم در موبایل */
        gap: 10px;
    }
}