:root {
    --primary-color: #4a90e2;
    --secondary-color: #f5a623;
    --background-color: #f4f7f6;
    --text-color: #333;
    --container-bg: #ffffff;
    --border-color: #ddd;
    --error-color: #d9534f;
    --success-color: #5cb85c;
    --font-family: 'Poppins', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    display: grid;
    /*place-items: center;*/
    /*margin-left:auto;
    margin-right:auto;*/
    min-height: 100vh;
}

#app {
    max-width: 100vw;
}

/* --- Auth Forms (Login/Register) --- */

.form-container {
    background: var(--container-bg);
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 420px;
    text-align: center;
    margin: auto;
}

.form-title {
    margin-bottom: 2rem;
    font-weight: 600;
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.25);
}

.btn {
    width: 100%;
    padding: 0.9rem;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:hover {
    background: #357ABD;
}

.btn:active {
    transform: scale(0.98);
}

.form-switch {
    margin-top: 2rem;
    font-size: 0.9rem;
}

.form-switch a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.form-switch a:hover {
    text-decoration: underline;
}

/* --- Flashes --- */
.flashes {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 8px;
    background-color: rgba(217, 83, 79, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(217, 83, 79, 0.2);
    transition: visibility 0.2s ease, height 0.2s ease, opacity 0.2s ease;
}

.flashes ul {
    list-style-type: none;
}

/* --- Dashboard --- */
.dashboard-container, .id-tags-container , .charging-profile-container {
    background: var(--container-bg);
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 95vw;
    margin: auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
    gap: 1.5rem;
    max-width: 100%;
}

.dashboard-header h2 {
    font-weight: 600;
}

.btn-regular {
    background: grey;
    padding: 0.5rem 1rem;
    width: auto;
}
.btn-regular:hover {
    background: #6c757d;
}

.btn-secondary {
    background: #28a745;
    padding: 0.5rem 1rem;
    width: fit-content;
    /*width: auto;
    height: auto;*/
}
.btn-secondary:hover {
    background: #218838;
}

.btn-danger {
    background: red;
    color: #fff;
    width: auto;
    padding: 0.5rem 1rem;
}

.btn-danger:hover {
    background: #c82333;
}

.add-data-form .input-group {
    display: flex;
}

.add-data-form input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.add-data-form .btn {
    width: auto;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.user-data-list {
    margin-top: 2.5rem;
}

.user-data-list ul {
    list-style: none;
    margin-top: 1rem;
}

.user-data-list li {
    background-color: #f8f9fa;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.user-data-list p {
    color: #6c757d;
    text-align: center;
    margin-top: 2rem;
}

.tabs {
    margin-bottom: 1em;
    /*padding: 0 2rem 0 2rem;*/
}
.tab-btn {
    display: inline-block;
    padding: 0.5em 1.2em;
    margin-right: 1em;
    border: none;
    background: #e0e0e0;
    color: #333;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}
.tab-btn.active {
    background: #fff;
    border-bottom: 2px solid #007bff;
    outline: none;
}
/*.tab-btn.active, .tab-btn:focus {
    background: #fff;
    border-bottom: 2px solid #007bff;
    outline: none;
}*/
.tab-btn2.active {
    background: #fff;
    border-bottom: 2px solid #007bff;
    outline: none;
}
.tab-btn2 {
    display: inline-block;
    padding: 0.5em 1.2em;
    margin-right: 1em;
    border: none;
    background: #e0e0e0;
    color: #333;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}
/*.tab-btn2.active, .tab-btn2:focus {
    background: #fff;
    border-bottom: 2px solid #007bff;
    outline: none;
}*/

.tab-btn3.active {
    background: #fff;
    border-bottom: 2px solid #007bff;
    outline: none;
}
.tab-btn3 {
    display: inline-block;
    padding: 0.5em 1.2em;
    margin-right: 1em;
    border: none;
    background: #e0e0e0;
    color: #333;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.gpu-section, .gpu-logs-section, .gpu-eeprom-section, gpu-location-section{
    margin-bottom: 2em;
}
.data-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    margin-bottom: 1em;
    table-layout: auto;
}
.data-table th, .data-table td {
    border: 1px solid #ddd;
    padding: 0.5em 0.8em;
    text-align: center;
}
.data-table th {
    background: #f5f5f5;
    font-weight: 600;
}
.data-table tr:nth-child(even) {
    background: #fafafa;
}

/*#charging-profile-table-actions {
    width: 16%;
}*/

/* Responsive enhancements */
#log-table-container,
#data-table-container,
#eeprom-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 500px;
}


#gpus-table-info {
    width: 25%;
}


/* Ensure GPU list table scrolls within section on small screens */
.gpu-section {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}


/* Prevent page-level horizontal scroll; inner containers will handle their own scroll */
html, body, #app {
    max-width: 100%;
    /*overflow-x: hidden;*/
}

/* Make sure sections that can contain tables provide a scroll context */
.gpu-logs-section,
.gpu-data-section,
.gpu-eeprom-section {
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    /*max-height: 500px;*/
}

/* Ensure table cells wrap long tokens instead of forcing overflow */
.data-table th,
.data-table td {
    word-break: break-word;
    overflow-wrap: anywhere;
}

.scrollable-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 500px;
}

#transaction-table-container, #reservation-table-container {
    max-height: 500px;
    overflow: auto;
}

.dashboard-content section {
    width: 100%;
    overflow-x: auto;
}

.map {
    height: 500px;
    /*width: 500px;*/
}

@media (max-width: 1024px) {
    .dashboard-container {
        max-width: 95vw;
        padding: 1.5rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.45em 0.6em;
    }
}

@media (max-width: 950px) { /* was 768*/
    body {
        padding: 0.5rem;
    }

    .form-container {
        padding: 1.5rem;
        max-width: 95vw;
    }

    .dashboard-container {
        padding: 1rem 1rem;
        max-width: 100vw;
        border-radius: 10px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .dashboard-header h2 {
        font-size: 1.15rem;
    }

    .btn-secondary {
        width: 100%;
    }

    .btn-danger {
        width: 100%;
    }

    #stop-modbus-btn {
        /*margin-top: 10px;*/
        margin-top: 0.75rem;
    }

    .tabs {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    .tab-btn,
    .tab-btn2,
    .tab-btn3 {
        white-space: nowrap;
        margin-right: 0; /* gap handles spacing on mobile */
        padding: 0.45em 0.9em;
        font-size: 0.95rem;
    }


    .data-table th,
    .data-table td {
        padding: 0.4em 0.55em;
        font-size: 0.95rem;
    }

    .data-table {
        table-layout: fixed;
        width: 100%;
    }
    .data-table th,
    .data-table td {
        word-break: break-word;
        overflow-wrap: anywhere;
        white-space: normal;
    }
}

@media (max-width: 480px) {
    .form-container {
        padding: 1.25rem;
    }

    .form-title {
        font-size: 1.25rem;
    }

    .btn,
    .btn-secondary {
        padding: 0.8rem;
        font-size: 0.95rem;
    }

    .tab-btn,
    .tab-btn2,
    .tab-btn3 {
        padding: 0.4em 0.75em;
        font-size: 0.9rem;
    }

    .tabs {
        margin-bottom: 0.75em;
    }


    .data-table th,
    .data-table td {
        font-size: 0.9rem;
        padding: 0.35em 0.5em;
    }

}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background-color: var(--container-bg);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 1rem;
    right: 1.5rem;
}

.close:hover,
.close:focus {
    color: var(--text-color);
    text-decoration: none;
}

.modal h3 {
    margin-bottom: 1rem;
}

.modal p {
    margin-bottom: 1.5rem;
    color: #666;
}

.modal .input-group {
    margin-bottom: 1.5rem;
}

.modal .input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.modal .input-group select {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal .input-group select[multiple] {
    min-height: 120px;
    padding: 0.5rem;
}

.modal .input-group select[multiple] option {
    padding: 0.5rem;
    margin-bottom: 0.25rem;
}

.modal .input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.25);
}

.modal .input-group input {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal .input-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 0;
    margin-top: 0.5rem;
    display: block;
}

.modal .input-group h3 {
    font-family: var(--font-family);
    font-weight: 400;
    font-size: 1rem;
}

.modal .btn {
    width: 100%;
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-content {
        margin: 10% auto;
        padding: 1.5rem;
        width: 95%;
    }

    #gpus-table {
		display: block;
		width: 100%;
	}

	#gpus-table thead {
		display: none;
	}

	#gpus-table tbody {
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
		gap: 1.5rem;
	}

	#gpus-table tr {
		display: flex;
		flex-direction: column;
		background: white;
		border: 1px solid var(--border-color);
		border-radius: 8px;
		padding: 1.5rem;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	}

	#gpus-table td {
		display: flex;
		justify-content: space-between;
		align-items: center;
		border: none;
		padding: 0.75rem 0;
		text-align: left;
		border-bottom: 1px solid #f0f0f0;
	}

	#gpus-table td:last-child {
		border-bottom: none;
	}

	#gpus-table td::before {
		content: attr(data-label);
		font-weight: 600;
		color: var(--primary-color);
		margin-right: 1rem;
		min-width: 120px;
	}

	#gpus-table td:nth-child(1)::before { content: "Serial Number"; }
	#gpus-table td:nth-child(2)::before { content: "Info"; }
	#gpus-table td:nth-child(3)::before { content: "Type"; }
	#gpus-table td:nth-child(4)::before { content: "Configuration"; }
	#gpus-table td:nth-child(5)::before { content: "Status"; }
	#gpus-table td:nth-child(6)::before { content: "Select"; }
	#gpus-table td:nth-child(7)::before { content: "Edit"; }
	#gpus-table td:nth-child(8)::before { content: "Delete"; }

	/* Uniform button styles in GPU table cards */
	#gpus-table button {
		width: 100% !important;
		padding: 0.6rem 0.8rem !important;
		font-size: 0.9rem !important;
		white-space: nowrap !important;
		height: 40px !important;
		display: flex !important;
		align-items: center !important;
		justify-content: center !important;
	}
}

/* Section transition helpers to avoid layout flicker when switching groups */
.section-fade {
    overflow: hidden; /* ensure max-height transition clips content */
    max-height: 0; /* collapsed by default */
    opacity: 0;
    transform: translateY(6px);
    visibility: hidden;
    pointer-events: none;
    /*transition: max-height 260ms ease, opacity 220ms ease, transform 220ms ease, visibility 260ms;*/
    /*transition: max-height 500ms ease, opacity 460ms ease, transform 460ms ease, visibility 500ms;*/
}

.section-fade.visible {
    /* large max-height to allow content to expand; adjust if you have taller content */
    /*max-height: 3200px;*/
    max-height: fit-content;
    opacity: 1;
    transform: none;
    visibility: visible;
    pointer-events: auto;
}

/* Small helper to hide instantly when needed (no transition) */
.section-fade.hidden-instant {
    max-height: 0 !important;
    opacity: 0 !important;
    transform: translateY(6px) !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

#modbus-parameter-detail-container{
    max-height: 500px !important;
    overflow: auto !important;
}

/* --- Currently not needed sections --- */
/*#charger-reservation-section, #charger-connector-section {
    display: none !important;
}*/

#charger-connector-section {
    display: none !important;
}


/* Ensure map container can take its space when visible */
/*#map {
    transition: opacity 220ms ease, transform 220ms ease;
}*/

#StopTransactionActions {
    width: 10%;
}


.badge-completed {
    color: green;
    font-weight: bold;
}

.status-online {
    color: green;
    font-weight: bold;
}

.operations-container .btn,
.operations-container .btn-secondary,
.operations-container .btn-danger {
    white-space: nowrap;   /* текст всегда в одну строку */
    height: 40px;          /* или любое фиксированное значение, которое вам подходит */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.operations-container{
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    max-width: 100%;
}

