/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
:root {
    --primary-color: #4CAF50;
    --primary-light: #81C784;
    --primary-dark: #388E3C;
    --secondary-color: #2196F3;
    --secondary-light: #64B5F6;
    --secondary-dark: #1976D2;
    --text-color: #212121;
    --bg-color: #E8F5E9;
    --white: #fff;
    --card-bg: #fdfdfd;
    --danger-color: #D32F2F;
    --success-color: #66BB6A;
    --border-radius-main: 15px;
    --border-radius-small: 8px;
    --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --button-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    --button-hover-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

html, body {
    height: 100%;
    margin: 0;
    overflow-x: hidden;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    font-size: 16px;
    line-height: 1.6;
}

.container {
    width: 95%;
    max-width: 1400px;
    margin: 20px auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: var(--border-radius-main);
    box-shadow: var(--box-shadow);
    margin-bottom: 25px;
}

header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    color: var(--white);
    padding: 20px 0;
    text-align: center;
    border-radius: var(--border-radius-main) var(--border-radius-main) 0 0;
    margin-bottom: 25px;
    position: relative;
    box-shadow: var(--box-shadow);
}

header h1 {
    margin: 0;
    font-size: 2.5em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header .user-info {
    font-size: 0.9em;
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.9);
    padding: 0 10px;
    word-break: break-word;
}

header .user-info a {
    color: #C8E6C9;
    text-decoration: none;
    transition: color 0.2s ease;
}

header .user-info a:hover {
    color: var(--white);
    text-decoration: underline;
}

.button, button {
    background: linear-gradient(45deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    padding: 12px 24px;
    text-decoration: none;
    border-radius: var(--border-radius-small);
    border: none;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    box-shadow: var(--button-shadow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.4;
    font-weight: 500;
    min-width: 120px;
    gap: 8px;
}

.button:hover, button:hover {
    background: linear-gradient(45deg, var(--primary-dark), var(--primary-color));
    box-shadow: var(--button-hover-shadow);
    transform: translateY(-2px);
}

.button:disabled, button:disabled {
    background-color: #bdbdbd;
    cursor: not-allowed;
    box-shadow: none;
    color: #757575;
    transform: none;
}

.button-secondary {
    background: linear-gradient(45deg, var(--secondary-color), var(--secondary-dark));
}
.button-secondary:hover {
    background: linear-gradient(45deg, var(--secondary-dark), var(--secondary-color));
}

.button-danger {
    background: linear-gradient(45deg, #f44336, #D32F2F);
}
.button-danger:hover {
    background: linear-gradient(45deg, #D32F2F, #f44336);
}

.button-telegram {
    background: linear-gradient(45deg, #0088CC, #0077B3);
}

.button-telegram:hover {
    background: linear-gradient(45deg, #0077B3, #0088CC);
}


.button-small {
    padding: 8px 16px;
    font-size: 0.9em;
    min-width: auto;
}

.dashboard-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 25px;
}

.dashboard-nav .button-nav {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
    color: var(--white);
    padding: 20px 30px;
    border-radius: var(--border-radius-main);
    flex: 1 1 200px;
    max-width: 250px;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.dashboard-nav .button-nav:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.dashboard-nav i {
    font-size: 1.5em;
    margin-bottom: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--primary-dark);
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius-small);
    font-size: 1em;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.alert {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: var(--border-radius-small);
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-danger {
    background-color: #ffebee;
    color: #c62828;
    border-color: #ef9a9a;
}

.alert-success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border-color: #a5d6a7;
}

#map {
    height: 70vh;
    width: 100%;
    border-radius: var(--border-radius-main);
    box-shadow: var(--box-shadow);
    z-index: 1;
}

.map-controls-group {
    background-color: var(--card-bg);
    padding: 15px;
    border-radius: var(--border-radius-main);
    box-shadow: var(--box-shadow);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.map-controls-group .map-control label {
    font-size: 0.9em;
    color: var(--text-color);
    font-weight: 500;
}

.map-controls-group .map-control select {
    padding: 8px;
    border-radius: var(--border-radius-small);
    border: 1px solid #ccc;
    font-size: 0.9em;
}

.leaflet-control-container .leaflet-draw-toolbar, .leaflet-control-container .leaflet-draw-actions {
    background-color: var(--card-bg);
    border: none;
    border-radius: var(--border-radius-small);
    box-shadow: var(--button-shadow);
    padding: 5px;
    color: var(--primary-dark);
}

.leaflet-draw-toolbar a {
    color: var(--primary-dark) !important;
}

.leaflet-pane.leaflet-overlay-pane path {
    stroke: rgba(0, 0, 0, 0.7) !important;
    stroke-width: 1.5px !important;
}

.territory-label {
    background-color: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    text-align: center;
    box-shadow: none;
    transform: translate(-50%, -50%);
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.7);
}

.main-content {
    flex: 3 1 600px;
    display: flex;
    flex-direction: column;
    min-width: 280px;
}

.sidebar {
    flex: 1 1 300px;
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius-main);
    box-shadow: var(--box-shadow);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    min-width: 250px;
}

.sidebar h3, h2 {
    color: var(--primary-dark);
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 500;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 8px;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-item {
    background-color: var(--white);
    padding: 15px;
    border-radius: var(--border-radius-small);
    border: 1px solid #eee;
    font-size: 0.95em;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.list-item .item-title {
    font-weight: 500;
}
.list-item .item-meta {
    font-size: 0.85em;
    color: #555;
    margin-top: 2px;
}
.list-item .item-actions {
    display: flex;
    gap: 8px;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 12px 0;
    border-bottom: 1px solid #ccc;
    margin-bottom: 10px;
    font-size: 1.2em;
    color: var(--primary-dark);
}

.collapsible-content {
    display: none;
    animation: fadeIn 0.4s ease;
}
.collapsible-content.active {
    display: block;
}

.search-container {
    margin-bottom: 15px;
}

.search-container input {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border-radius: var(--border-radius-small);
    border: 1px solid #ccc;
}

footer {
    text-align: center;
    margin-top: auto;
    padding: 15px;
    color: #777;
    font-size: 0.9em;
    border-top: 1px solid #dcedc8;
}

#ajax-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10000;
    display: none;
}

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

.tabs {
    display: flex;
    border-bottom: 2px solid #ddd;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 5px;
}

.tab-button {
    padding: 12px 18px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 1.05em;
    color: #555;
    flex-shrink: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-button:hover {
    background-color: #f0f0f0;
}

.tab-button.active {
    border-bottom: 3px solid var(--primary-color);
    font-weight: 500;
    color: #333;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

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

.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 30px;
    border: 1px solid #888;
    border-radius: var(--border-radius-main);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--box-shadow);
    animation: zoomIn 0.3s ease;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 32px;
    font-weight: bold;
    transition: color 0.2s;
}

.close-button:hover, .close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.welcome-section {
    text-align: center;
    padding: 50px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.welcome-section h2 {
    font-size: 3em;
    color: var(--primary-dark);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.welcome-section p {
    font-size: 1.2em;
    color: #555;
    text-align: center;
}

.welcome-section .buttons {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}
.registration-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.telegram-integration-card {
    margin-top: 20px;
    text-align: center;
}
.button-telegram {
    background: linear-gradient(45deg, #0088CC, #0077B3);
    padding: 15px 30px;
    font-size: 1.1em;
    box-shadow: 0 4px 10px rgba(0, 136, 204, 0.3);
}
.button-telegram:hover {
    background: linear-gradient(45deg, #0077B3, #0088CC);
    box-shadow: 0 6px 15px rgba(0, 136, 204, 0.4);
    transform: translateY(-2px);
}
.telegram-instruction {
    text-align: left;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}
.telegram-instruction h3 {
    margin-bottom: 10px;
    font-size: 1.3em;
    color: #212121;
}
.telegram-instruction ol {
    margin: 0;
    padding-left: 20px;
}
.telegram-instruction li {
    margin-bottom: 10px;
}
.telegram-instruction code {
    background-color: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #c62828;
}

@media(max-width: 768px) {
    .container {
        width: 98%;
        padding: 10px;
    }

    .card {
        padding: 1.5rem;
    }

    .dashboard-nav .button-nav {
        font-size: 1em;
        padding: 15px 20px;
    }

    .dashboard-nav i {
        font-size: 1.2em;
    }

    h2, h3 {
        font-size: 1.2em;
    }
}
