/* Main styles */
:root {
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --secondary-color: #f72585;
    --success-color: #4cc9f0;
    --info-color: #4895ef;
    --warning-color: #fca311;
    --danger-color: #e63946;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --body-bg: #f8f9fa;
    --card-bg: #ffffff;
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.05);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 1rem 2rem rgba(0, 0, 0, 0.1);
    --border-radius: 0.5rem;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--body-bg);
    color: #495057;
    line-height: 1.6;
}

/* Login styles */
.login-container {
    margin-top: 100px;
    max-width: 460px;
}

.login-container .card {
    box-shadow: var(--shadow-md);
    border-radius: var(--border-radius);
    border: none;
}

.login-form .form-control {
    padding: 0.8rem 1rem;
    border-radius: 0.375rem;
    transition: var(--transition);
}

/* Navigation styles */
.navbar {
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 1rem;
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    transition: var(--transition);
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Dashboard styles */
.page-header {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 0;
    font-size: 1.75rem;
}

/* Card styling */
.card {
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: none;
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background-color: var(--card-bg);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding: 1rem 1.5rem;
}

/* Button styles */
.btn {
    padding: 0.5rem 1.25rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: var(--transition);
}

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

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

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

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

/* Table styling */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    font-weight: 600;
    color: var(--dark-color);
    background-color: rgba(0, 0, 0, 0.02);
    border-bottom-width: 1px;
    padding: 1rem;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--border-radius);
}

/* Modal styling */
.modal-content {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background-color: var(--card-bg);
}

.modal-header .modal-title {
    font-weight: 600;
    color: var(--dark-color);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background-color: var(--card-bg);
}

/* Form styling */
.form-label {
    font-weight: 500;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.form-control {
    padding: 0.6rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.375rem;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.15);
}

.form-select {
    padding: 0.6rem 1rem;
    border-radius: 0.375rem;
}

/* Toast styling */
.toast {
    min-width: 300px;
    background-color: var(--card-bg);
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.toast-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--dark-color);
    padding: 0.75rem 1rem;
}

.toast-body {
    padding: 1rem;
}

/* Pagination styling */
.pagination {
    margin-bottom: 0;
    margin-top: 1.5rem;
}

.page-item:first-child .page-link {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

.page-item:last-child .page-link {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

.page-link {
    padding: 0.5rem 1rem;
    color: var(--primary-color);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

.page-link:hover {
    background-color: rgba(67, 97, 238, 0.1);
    color: var(--primary-hover);
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Search input styling */
.search-container {
    position: relative;
    max-width: 500px;
    margin-bottom: 1.5rem;
}

.search-container .form-control {
    padding-left: 2.5rem;
    border-radius: 50rem;
    background-color: #fff;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
}

/* Custom badges */
.badge {
    padding: 0.4em 0.8em;
    font-weight: 500;
    border-radius: 50rem;
}

/* Utility classes */
.shadow-hover:hover {
    box-shadow: var(--shadow-md);
}

.border-dashed {
    border-style: dashed !important;
}

/* Calendar styling */
#calendar {
    height: auto;
    min-height: 800px;
}

.fc-theme-standard .fc-list,
.fc-theme-standard .fc-scrollgrid,
.fc-theme-standard th,
.fc-theme-standard td {
    border-color: rgba(0, 0, 0, 0.08);
}

.fc .fc-toolbar-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.fc .fc-button-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.fc .fc-button-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Client detail styles */
.client-detail-card {
    position: sticky;
    top: 2rem;
}

.client-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.client-info {
    margin-bottom: 0.75rem;
}

.client-info-label {
    font-weight: 500;
    color: #6c757d;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.client-info-value {
    font-weight: 400;
}

.client-notes {
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 0.375rem;
    padding: 1rem;
    margin-top: 1rem;
}

/* Search input legacy styling (keep for compatibility) */
#searchInput {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

#searchButton {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Select2 styling */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 41px;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.375rem;
    transition: var(--transition);
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.15);
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    padding-left: 0;
    padding-right: 0;
    color: #495057;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 100%;
    right: 10px;
}

.select2-container--bootstrap-5 .select2-dropdown {
    border-color: var(--primary-color);
    border-radius: 0.375rem;
    box-shadow: var(--shadow-md);
}

.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary-color);
    color: white;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.375rem;
    padding: 0.6rem 1rem;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.15);
    outline: none;
}

.input-group .select2-container {
    flex: 1 1 auto;
    width: 1% !important;
}

.select2-container {
    width: 100% !important;
}

/* Ensure alignment with input-group-text */
.input-group > .select2-container--bootstrap-5 .select2-selection {
    height: 100%;
    line-height: 1.5;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Responsive adjustments */
/* Tablets and small desktops */
@media (max-width: 992px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-header .btn {
        align-self: flex-start;
        margin-top: 0.5rem;
    }

    /* Calendar layout adjustments */
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 10px;
    }
    
    .fc .fc-toolbar-title {
        margin-bottom: 10px;
    }
    
    /* Calendar view buttons */
    .fc .fc-button-group {
        display: flex;
        width: 100%;
    }
    
    .fc .fc-button-group .fc-button-primary {
        flex: 1;
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    /* General adjustments */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .card-header {
        padding: 0.85rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 1.5rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Calendar adjustments */
    #calendar {
        height: auto;
        min-height: 600px;
    }
    
    .fc .fc-toolbar.fc-header-toolbar {
        margin-bottom: 0.5em;
    }
    
    .fc-header-toolbar .fc-toolbar-chunk {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        margin-bottom: 5px;
    }
    
    .fc .fc-toolbar-title {
        font-size: 1.2rem;
    }
    
    /* Improved table for mobile */
    .table-responsive table {
        width: 100%;
        table-layout: fixed;
    }
    
    .responsive-table-card {
        margin-bottom: 1rem;
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-sm);
        overflow: hidden;
    }
    
    .responsive-table-card .card-body {
        padding: 0;
    }
    
    /* Client details panel on smaller screens */
    .client-detail-card {
        position: static;
        margin-top: 1rem;
    }
    
    /* Form controls in modals */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .input-group > .input-group-text {
        padding: 0.4rem 0.75rem;
    }
    
    /* Button group adjustments */
    .btn-group-sm > .btn {
        padding: 0.25rem 0.5rem;
    }
    
    /* Make full calendar more touch-friendly */
    .fc-event {
        padding: 4px !important;
        font-size: 12px !important;
    }
    
    .fc-timegrid-slot {
        height: 2.5em !important;
    }
    
    /* Adjust navbar for mobile */
    .navbar-brand {
        font-size: 1.2rem;
    }
}

/* Extra small devices */
@media (max-width: 575.98px) {
    /* Override table responsive behavior for very small screens */
    .table-responsive {
        overflow-x: auto;
    }
    
    /* Hide less important columns and show them as details */
    .table-sm-responsive th:nth-child(4),
    .table-sm-responsive th:nth-child(5),
    .table-sm-responsive th:nth-child(6),
    .table-sm-responsive td:nth-child(4),
    .table-sm-responsive td:nth-child(5),
    .table-sm-responsive td:nth-child(6) {
        display: none;
    }
    
    /* Скрыть иконки мессенджеров на мобильных устройствах */
    .d-md-none .btn-outline-success,
    .d-md-none .btn-outline-info {
        display: none !important;
    }
    
    /* Bigger touch targets */
    .btn {
        padding: 0.5rem 0.75rem;
    }
    
    /* More compact modals */
    .modal-footer {
        padding: 0.75rem;
    }
    
    .modal-header {
        padding: 0.75rem 1rem;
    }
    
    /* Calendar special handling for phones */
    #calendar {
        min-height: 500px;
    }
    
    .fc-toolbar-chunk:last-child {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .fc-toolbar-chunk:last-child .fc-button-group {
        margin-top: 5px;
    }
    
    /* More touch-friendly calendar height */
    .fc-timegrid-slot {
        height: 3em !important;
    }
    
    .fc-event-time {
        font-size: 11px !important;
    }
}
