/* --- General Styles & Resets --- */
:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --background-color: #e9ecef;
    --border-radius: 5px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--dark-color);
    line-height: 1.5;
}

.container {
    max-width: 960px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
}

header {
    background-color: var(--dark-color);
    color: var(--light-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

header .parking-selector-container {
    display: flex;
    align-items: center;
    gap: 10px;
}
header .parking-selector-container label {
    margin: 0;
    font-weight: normal;
}
header .parking-selector-container select {
    background-color: #5d646b;
    color: white;
    border: 1px solid #999;
}


/* --- Forms & Buttons --- */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: .5rem;
    font-weight: bold;
}

input[type="text"],
input[type="password"],
input[type="tel"],
input[type="time"],
input[type="date"],
input[type="number"] {
    width: 100%;
    padding: .5rem;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    box-sizing: border-box;
}

select {
    width: 100%;
    padding: .5rem;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    background-color: #fff;
    box-sizing: border-box;
}

button {
    position: relative; /* Needed for spinner positioning */
    display: inline-block;
    padding: .6rem 1.2rem;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    background-color: var(--primary-color);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s;
    vertical-align: middle;
}
 
button:hover {
    background-color: var(--primary-hover);
}

button:disabled,
button[disabled]{
    background-color: var(--secondary-color);
    opacity: 0.65;
    cursor: not-allowed;
    box-shadow: none;
}

button:disabled:hover,
button[disabled]:hover {
    background-color: var(--secondary-color); /* Prevent hover effect */
}

/* --- Spinner/Loading State for Buttons --- */
.button--loading .button-text {
    visibility: hidden;
    opacity: 0;
}

.button--loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    border: 3px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s ease infinite;
}

.danger-btn {
    background-color: var(--danger-color);
}
.danger-btn:hover {
    background-color: #a71d2a;
}

@keyframes spin {
    from { transform: rotate(0turn); }
    to { transform: rotate(1turn); }
}


.shortcut-btn {
    background-color: var(--light-color);
    color: var(--dark-color);
    border: 1px solid #ccc;
    font-weight: 500;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    padding: .5rem .8rem;
    text-align: center;
}
.shortcut-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.button-main-text {
    font-size: 0.9em;
    font-weight: 500;
}
.button-sub-text {
    font-size: 0.75em;
    color: var(--secondary-color);
}


.shortcut-btn:hover:not(.active) {
    background-color: #e9ecef;
    border-color: #bbb;
}

.shortcut-btn.active {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-hover);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    transform: translateY(1px);
}
.shortcut-btn.active .button-main-text{
    font-weight: bold;
}
.shortcut-btn.active .button-sub-text {
    color: rgba(255, 255, 255, 0.85);
}


/* --- Auth Forms --- */
#auth-container {
    max-width: 400px;
    margin: 0 auto;
}

.hidden {
    display: none;
}

#auth-container p {
    margin-top: 1rem;
    text-align: center;
}

/* --- Messages --- */
#message-area {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: bold;
    min-height: 1em;
}
.message-success {
    background-color: #d4edda;
    color: #155724;
}
.message-error {
    background-color: #f8d7da;
    color: #721c24;
}

.error-message {
    color: #721c24;
    font-size: 0.9em;
    display: block;
    min-height: 1em; /* Prevents layout shift when message appears */
}

.date-controls-container {
    display: flex;
    align-items: center;
    gap: 10px;
}
.date-controls-container input[type="date"] {
    flex-grow: 1;
}

.phone-input-container {
    display: flex;
    align-items: center;
    gap: 5px;
}
.phone-input-container select {
    width: auto; 
    flex-shrink: 0;
}
.phone-input-container input[type="tel"] {
    flex-grow: 1;
}
/* --- Admin Controls --- */
.controls {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--light-color);
    border-radius: var(--border-radius);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}
.form-group-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
}
.form-group-inline.time-slider-row {
    width: 100%;
    display: block;
    margin-bottom: 1rem;
}

/* --- OOS Management --- */
#manage-oos-btn.active {
    background-color: var(--danger-color);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}
.oos-management-mode .parking-space {
    outline: 2px dashed var(--danger-color);
    outline-offset: 2px;
}
/* --- Tab Navigation --- */
.tabs {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 1.5rem;
}

.time-slider, #layout-time-slider {
    width: 100%;
    max-width: 900px;
    min-width: 300px;
    height: 2.5em;
    margin: 0 auto 0.5em auto;
    display: block;
    accent-color: var(--primary-color);
    /* Remove background override to restore original style */
}

/* Make the thumb and track larger for better usability */
.time-slider::-webkit-slider-thumb, #layout-time-slider::-webkit-slider-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: pointer;
}
.time-slider::-webkit-slider-runnable-track, #layout-time-slider::-webkit-slider-runnable-track {
    height: 12px;
    border-radius: 6px;
    background: #e0e0e0;
}

.time-slider::-moz-range-thumb, #layout-time-slider::-moz-range-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: pointer;
}
.time-slider::-moz-range-track, #layout-time-slider::-moz-range-track {
    height: 12px;
    border-radius: 6px;
    background: #e0e0e0;
}

.time-slider::-ms-thumb, #layout-time-slider::-ms-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: pointer;
}
.time-slider::-ms-fill-lower, .time-slider::-ms-fill-upper, #layout-time-slider::-ms-fill-lower, #layout-time-slider::-ms-fill-upper {
    background: #e0e0e0;
    border-radius: 6px;
}

/* For Firefox */
.time-slider, #layout-time-slider {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) #e0e0e0;
}


.tab-link {
    background: none;
    border: none;
    color: var(--primary-color);
    padding: .75rem 1.25rem;
    font-size: 1rem;
    border-bottom: 2px solid transparent;
}
.tab-link.active {
    color: var(--dark-color);
    border-color: var(--primary-color);
    font-weight: bold;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* --- Admin Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
th, td {
    padding: .75rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}
th {
    background-color: var(--light-color);
}

/* --- Parking Layout --- */
#parking-layout-container {
    margin-top: 1.5rem;
}
.parking-line {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed #ccc;
}
.parking-line h3 {
    margin-top: 0;
}
.spaces-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.parking-space {
    position: relative; /* Needed for the ::before pseudo-element */
    border: 2px solid var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 0.3rem;
    padding-left: 0.5rem; /* Add padding to not overlap the "wall" */
    min-width: 120px;
    text-align: center;
    cursor: pointer;
    font-size: 0.9em;
}
.parking-space.disponible {
    border-color: #28a745;
    color: #28a745;
}
.parking-space.asignado {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}
.parking-space.bloqueado {
    background-color: var(--danger-color);
    color: #fff;
    border-color: var(--danger-color);
}
.parking-space.fuera_de_servicio {
    background-color: #555;
    color: #fff;
    border-color: #333;
    cursor: pointer; /* Still clickable in management mode */
    background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
    background-size: 40px 40px;
}

.parking-space.is-first-space::before {
    content: '';
    position: absolute;
    left: -2px; /* Position it over the left border */
    top: -2px;
    bottom: -2px;
    width: 8px; /* Width of the "wall" */
    background-color: #5d646b; /* A dark, neutral color like a wall */
    border-radius: 4px 0 0 4px; /* Round the corners on the left side */
    border: 1px solid #343a40;
}

.space-info {
    font-size: 0.9em;
    margin-top: 0.5rem;
    line-height: 1.4;
}

/* --- List Styles (Vehicles & Parkings) --- */
.list-item-container {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e0e0e0;
}
.list-item:last-child {
    border-bottom: none;
}
.list-item-info {
    display: flex;
    flex-direction: column;
}
.list-item-main-text {
    font-weight: bold;
}
.list-item-sub-text {
    font-size: 0.9em;
    color: var(--secondary-color);
}

/* --- Reservation List --- */
.assignment-item {
    position: relative;
    padding: 15px 80px 15px 15px;
    margin-bottom: 10px;
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.assignment-item.expired-reservation {
    background-color: #f8f9fa;
    border-left: 4px solid var(--secondary-color);
    opacity: 0.8;
}

.assignment-item p {
    margin: 0.25em 0;
}
.assignment-item .highlight {
    font-weight: bold;
    color: var(--primary-hover);
}

.expired-tag {
    font-weight: bold;
    color: var(--danger-color);
}

.assignment-actions {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
}

/* --- Icon Buttons --- */
.icon-btn {
    background: none;
    border: none;
    padding: 5px;
    margin: 0 2px;
    cursor: pointer;
    font-size: 1.1em;
    color: var(--secondary-color);
    transition: color 0.2s, transform 0.2s;
    vertical-align: middle;
}

.icon-btn:hover {
    transform: scale(1.2);
}

.icon-btn.danger {
    color: var(--danger-color);
}

.icon-btn.danger:hover {
    color: #a71d2a;
}

/* For admin table actions */
.actions-cell {
    white-space: nowrap;
    text-align: center;
}
.actions-cell .icon-btn {
    font-size: 1.2em;
    margin: 0 5px;
}
.actions-cell .edit-parking-btn:hover {
    color: var(--primary-hover);
}
.actions-cell .regenerate-code-btn:hover {
    color: #28a745; /* Green for regenerate */
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-overlay.active {
    display: flex;
}

.modal-content {
    background-color: #fff;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-top: 0;
}

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.danger-zone {
    border: 2px solid var(--danger-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-top: 1.5rem;
    background-color: #f8d7da;
}
.danger-zone h4 {
    margin-top: 0;
    color: #721c24;
}

/* --- Slider Reservation Bar --- */
#slider-reservation-bar {
    position: absolute;
    left: 0;
    top: 2px;
    height: 20px !important;
    min-height: 16px;
    width: 100%;
    border-radius: 10px;
    pointer-events: none;
    z-index: 5;
    background: #e0e0e0;


    transform: translateY(-50%);
    transition: background 0.2s;
}
.time-slider {
    position: relative;
    z-index: 10;
    background: transparent !important;
    /* Remove default track color for Chrome */
}
.time-slider::-webkit-slider-runnable-track {
    background: transparent !important;
}
.time-slider::-moz-range-track {
    background: transparent !important;
}
.time-slider::-ms-fill-lower, .time-slider::-ms-fill-upper {
    background: transparent !important;
}



/* --- Responsive Design --- */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
        margin: 1rem;
    }
    header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
}

@media (max-width: 600px) {
    .tabs {
        flex-direction: column;
        align-items: stretch;
        border-bottom: none;
    }
    .tab-link {
        text-align: center;
        border-bottom: 1px solid #dee2e6;
        border-radius: 0;
    }
}