/**
 * Surveying Calculation Tool - Custom Styles (Responsive Enhanced)
 */

/* Global Styles */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #212529;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f7fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
}

/* Avatar Circle */
.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* Cards */
.card {
    border-radius: 12px;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1) !important;
}

.card-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 12px 12px 0 0 !important;
}

/* Tables */
.table {
    font-size: 0.875rem;
}

.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Forms */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.input-group-text {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}

/* Buttons */
.btn {
    font-weight: 500;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
    transform: translateY(-1px);
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.5em 0.75em;
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
}

/* Navigation */
.navbar {
    padding: 0.75rem 1rem;
}

.navbar-brand {
    font-size: 1.25rem;
}

.nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Dropdown */
.dropdown-menu {
    border: none;
    border-radius: 12px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.dropdown-item {
    padding: 0.5rem 1rem;
    font-weight: 500;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

.dropdown-item.active {
    background-color: var(--primary-color);
}

/* Stats Cards */
.stat-card {
    border-radius: 12px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: #2c3e50;
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Project Cards */
.project-card {
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Template Cards */
.template-card {
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Station Rows */
.station-row {
    background: #f8f9fa;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.station-row:hover {
    background: #e9ecef;
}

/* Calculation Table */
.calculation-table {
    font-size: 0.8125rem;
}

.calculation-table th {
    font-size: 0.6875rem;
    white-space: nowrap;
}

.rod-reading-cell {
    background-color: rgba(13, 110, 253, 0.05);
}

.point-elev-cell {
    background-color: rgba(25, 135, 84, 0.05);
}

.station-cell {
    background-color: rgba(0, 0, 0, 0.03);
}

/* Modal */
.modal-content {
    border: none;
    border-radius: 16px;
}

.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Accordion */
.accordion-item {
    border: none;
    background: transparent;
}

.accordion-button {
    font-weight: 500;
    border-radius: 8px !important;
}

.accordion-button:not(.collapsed) {
    background-color: rgba(13, 110, 253, 0.1);
    color: var(--primary-color);
}

/* Flash Messages */
.flash-message-container {
    z-index: 9999;
}

/* Footer */
footer {
    margin-top: auto;
}

/* Print Styles */
@media print {
    .navbar,
    .btn-group,
    .flash-message-container,
    .no-print {
        display: none !important;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
    
    .calculation-table {
        font-size: 9pt;
    }
    
    body {
        background: white;
    }
}

/* Responsive Adjustments */

/* Small devices (landscape phones, 576px and up) */
@media (max-width: 576px) {
    h1 {
        font-size: 1.75rem;
    }
    h2 {
        font-size: 1.5rem;
    }
    .stat-number {
        font-size: 1.25rem;
    }
    .stat-icon {
        width: 35px;
        height: 35px;
        font-size: 1.1rem;
    }
    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
    .table {
        font-size: 0.75rem;
    }
    .calculation-table {
        font-size: 0.7rem;
    }
    .calculation-table th,
    .calculation-table td {
        padding: 0.4rem 0.2rem;
    }
    /* Make station rows stack on mobile */
    .station-row .row > div {
        margin-bottom: 0.5rem;
    }
    .station-row .row > div:last-child {
        margin-bottom: 0;
    }
    .station-row .col-2 {
        width: 100%;
        text-align: center;
    }
    .station-row .btn-sm {
        width: 100%;
    }
    /* Adjust card padding */
    .card-body {
        padding: 1rem;
    }
    /* Full-width buttons on mobile */
    .btn-group.w-100 {
        flex-wrap: wrap;
    }
    .btn-group.w-100 .btn {
        flex: 1 1 auto;
        margin-bottom: 0.25rem;
    }
    /* Flash message on mobile */
    .flash-message-container {
        width: 90%;
        left: 5%;
        transform: none;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (max-width: 768px) {
    .stat-number {
        font-size: 1.5rem;
    }
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    .calculation-table {
        font-size: 0.75rem;
    }
    .calculation-table th,
    .calculation-table td {
        padding: 0.5rem 0.25rem;
    }
    /* Improve table readability on tablets */
    .table th {
        font-size: 0.7rem;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container-fluid {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert {
    animation: fadeIn 0.3s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Form Validation */
.was-validated .form-control:invalid,
.was-validated .form-select:invalid {
    border-color: var(--danger-color);
}

.was-validated .form-control:valid,
.was-validated .form-select:valid {
    border-color: var(--success-color);
}

.invalid-feedback {
    font-size: 0.8125rem;
}

/* Tooltips */
.tooltip {
    font-size: 0.75rem;
}

/* Code Blocks */
code {
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.875em;
    color: #d63384;
}

/* Login/Register Pages */
.brand-icon {
    font-size: 4rem;
    color: var(--primary-color);
}

.feature-item {
    padding: 0.5rem;
}

.feature-item i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    color: var(--primary-color);
}

/* Chart Containers */
canvas {
    max-height: 400px;
}

/* ========= Mobile Touch Optimizations ========= */
button,
.btn,
.form-control,
.form-select,
input,
textarea,
[role="button"] {
    touch-action: manipulation; /* جلوگیری از بزرگ‌نمایی خودکار در iOS */
    -webkit-appearance: none;   /* حذف استایل پیش‌فرض iOS */
    appearance: none;
}

/* جلوگیری از تشخیص خودکار شماره تلفن در iOS */
input[type="tel"],
input[type="text"],
input[type="email"],
input[type="password"] {
    -webkit-touch-callout: none;
}

/* افزایش اندازه ناحیه کلیک برای دکمه‌های کوچک */
.btn-sm {
    min-height: 44px; /* اندازه توصیه‌شده برای موبایل */
}