/* Основные стили для дашборда */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 300;
}

.header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Стили для вкладок */
.tabs-section {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.tabs {
    display: flex;
    padding: 0 25px;
    gap: 0;
}

.tab-button {
    background: #f8f9fa;
    border: none;
    padding: 15px 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-button:hover {
    background: #e9ecef;
    color: #2c3e50;
}

.tab-button.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

.tab-content {
    display: none;
}

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

.filters-section {
    padding: 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.filter-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: end;
}

.filter-item {
    flex: 1;
    min-width: 200px;
}

.filter-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
}

.filter-item select, .filter-item input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.filter-item select:focus, .filter-item input:focus {
    border-color: #667eea;
    outline: none;
}

/* Специальные стили для диапазона дат */
#customDateRange {
    min-width: 300px;
}

#customDateRange .date-range-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
}

#customDateRange .date-range-inputs input {
    flex: 1;
    min-width: 140px;
}

#customDateRange .date-range-separator {
    color: #6c757d;
    font-weight: bold;
    padding: 0 5px;
}

.apply-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.2s;
    white-space: nowrap;
}

.apply-btn:hover {
    transform: translateY(-2px);
}

.clear-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.2s;
    white-space: nowrap;
}

.clear-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.quick-actions {
    padding: 20px 25px;
    background: white;
    border-bottom: 1px solid #e9ecef;
}

.quick-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.quick-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    white-space: nowrap;
}

.quick-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #667eea;
}

.quick-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.results-section {
    padding: 25px;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    text-align: center;
    border-left: 5px solid #667eea;
    transition: transform 0.3s;
}

.summary-card:hover {
    transform: translateY(-5px);
}

.summary-card h3 {
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.summary-card .value {
    font-size: 2.2em;
    font-weight: 700;
    color: #2c3e50;
}

.summary-card .subtext {
    font-size: 0.8em;
    color: #28a745;
    margin-top: 5px;
}

/* Стили для секции графиков - ВЕРТИКАЛЬНОЕ РАСПОЛОЖЕНИЕ */
.charts-section {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chart-container {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    border-left: 5px solid #667eea;
}

.chart-container h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.1em;
}

.chart-container canvas {
    max-height: 300px;
    width: 100% !important;
}

/* Стили для графика сравнения */
#comparisonChartContainer {
    width: 100%;
}

.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
}

td {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
}

tr:hover {
    background: #f8f9fa;
}

.employee-name {
    font-weight: 600;
    color: #2c3e50;
}

.activity-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.badge-call { background: #e3f2fd; color: #1976d2; }
.badge-comment { background: #f3e5f5; color: #7b1fa2; }
.badge-task { background: #e8f5e8; color: #388e3c; }
.badge-meeting { background: #fff3e0; color: #f57c00; }

/* Стили для стадий сделок */
.stage-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    color: white;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

/* === Панель детализации активностей === */
.details-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 800px;
    height: 100vh;
    background: white;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease, visibility 0.3s;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.details-panel.active {
    transform: translateX(0);
    visibility: visible;
}

.details-header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.details-header h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
}

.details-header button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.details-header button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.details-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f9fafb;
}

.day-group {
    margin-bottom: 20px;
    padding: 16px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.day-header {
    font-weight: 600;
    font-size: 1.1em;
    color: #2c3e50;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.activity-item {
    padding: 10px 0;
    border-bottom: 1px solid #f1f3f4;
}

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

.activity-line {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.activity-time {
    font-weight: 600;
    color: #495057;
    min-width: 70px;
    font-size: 0.9em;
}

.activity-type {
    font-size: 0.8em;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    white-space: nowrap;
    min-width: 90px;
    text-align: center;
}

.activity-description {
    color: #555;
    font-size: 0.95em;
    line-height: 1.5;
    word-wrap: break-word;
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    white-space: pre-wrap;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: auto;
}

.loading, .error {
    padding: 30px;
    text-align: center;
    color: #6c757d;
}

.error {
    color: #e74c3c;
}

/* Стили для админ-панели */
.admin-section {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.admin-section h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.1em;
}

.admin-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-actions .auth-btn {
    margin-bottom: 0;
}

.system-info {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.system-info p {
    margin: 8px 0;
    color: #495057;
}

/* Адаптивность */
@media (max-width: 1200px) {
    .summary-cards {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    .filter-group {
        gap: 15px;
    }
    .filter-item {
        min-width: 180px;
    }
    #customDateRange {
        min-width: 280px;
    }
    .tabs {
        padding: 0 20px;
    }
}

@media (max-width: 992px) {
    .filter-group {
        flex-direction: column;
    }
    .filter-item {
        min-width: 100%;
    }
    #customDateRange {
        min-width: 100%;
    }
    .apply-btn, .clear-btn {
        width: 100%;
        margin-top: 10px;
    }
    .admin-actions {
        flex-direction: column;
    }
    
    .admin-section {
        padding: 15px;
    }
    .tabs {
        flex-wrap: wrap;
    }
    .tab-button {
        flex: 1;
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    .summary-cards {
        grid-template-columns: 1fr 1fr;
    }
    .quick-buttons {
        justify-content: center;
    }
    .quick-btn {
        padding: 8px 16px;
        font-size: 0.9em;
    }
    .header h1 {
        font-size: 2em;
    }
    body {
        padding: 10px;
    }
    .filters-section {
        padding: 20px;
    }
    .results-section {
        padding: 20px;
    }
    .details-panel {
        max-width: 100%;
        width: 100%;
    }
    .activity-line {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .activity-time, .activity-type {
        min-width: auto;
    }
    .chart-container {
        padding: 15px;
    }
    .tabs {
        padding: 0 15px;
    }
    .tab-button {
        padding: 12px 15px;
        font-size: 13px;
    }
}

@media (max-width: 576px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }
    .filter-group {
        gap: 10px;
    }
    #customDateRange .date-range-inputs {
        flex-direction: column;
        gap: 8px;
    }
    #customDateRange .date-range-separator {
        display: none;
    }
    .quick-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    .quick-btn {
        text-align: center;
    }
    .header {
        padding: 20px;
    }
    .header h1 {
        font-size: 1.8em;
    }
    .tabs {
        flex-direction: column;
    }
    .tab-button {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .dashboard {
        border-radius: 10px;
    }
    .filters-section {
        padding: 15px;
    }
    .results-section {
        padding: 15px;
    }
    .summary-card {
        padding: 20px;
    }
    .summary-card .value {
        font-size: 1.8em;
    }
    th, td {
        padding: 10px 8px;
    }
    .activity-badge {
        padding: 3px 6px;
        font-size: 0.75em;
    }
}

/* Улучшения для полей ввода дат */
input[type="date"] {
    min-height: 44px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    padding: 4px;
    cursor: pointer;
}

/* Улучшения для контейнера фильтров */
.filter-group {
    align-items: stretch;
}

.filter-item {
    display: flex;
    flex-direction: column;
}

.filter-item > label {
    margin-bottom: 8px;
}

.load-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.2s;
    white-space: nowrap;
}

.load-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #38a169, #2f855a);
}

.load-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

.pagination-info {
    font-size: 14px;
    color: #6c757d;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pagination-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.pagination-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.pagination-page {
    font-size: 14px;
    font-weight: 600;
}