:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #8b5cf6;
    --text-main: #f1f5f9;
    --text-sub: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #334155;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(20px);
    border-radius: 0;
    border: none;
    /* Full screen mobile feel */
    box-shadow: none;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    /* Enable vertical scroll */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.logo i {
    font-size: 1.8rem;
    background: linear-gradient(45deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--text-sub);
    transition: background-color 0.3s;
}

.status-indicator.running .dot {
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: pulse 2s infinite;
}

.status-indicator.stopped .dot {
    background-color: var(--text-sub);
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

main {
    flex: 1;
    overflow: visible;
    /* Allow content to flow and scroll */
    padding-bottom: 80px;
    /* Space for fixed bottom buttons */
}

.grid-container {
    display: flex;
    flex-direction: column;
    /* Vertical Stack */
    gap: 20px;
    height: auto;
}

.card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: transform 0.2s;
}

.card:hover {
    border-color: rgba(59, 130, 246, 0.5);
}

h2 {
    font-size: 1.1rem;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Increased from 8px for better readability */
}

label {
    font-size: 0.85rem;
    color: var(--text-sub);
    font-weight: 600;
}

input,
select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    border-color: var(--primary);
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.row input {
    flex: 1;
}

/* Station Row specific adjustments */
.station-row input {
    width: 100%;
    min-width: 80px;
}

.time-range {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
}

.separator {
    color: var(--text-sub);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-main);
    font-weight: 400;
}

.passenger-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.p-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
}

.counter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.counter button {
    width: 30px;
    height: 30px;
    border-radius: 5px;
    border: none;
    background: var(--border);
    color: var(--text-main);
    cursor: pointer;
}

.counter button:hover {
    background: var(--primary);
}

.action-buttons {
    display: flex;
    justify-content: center;
    padding: 10px 0;
    border-top: 1px solid var(--border);
    margin-top: 20px;
}

.btn-wrapper {
    /* Wrapper to constrain button width to max-width */
    width: 100%;
    max-width: 560px;
    /* Slightly less than 600px padding */
    display: flex;
    gap: 10px;
}

.btn-main {
    flex: 2;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 50px;
}

.btn-main:hover {
    filter: brightness(1.1);
}

.btn-main:active {
    transform: scale(0.98);
}

.btn-main.running {
    background: linear-gradient(135deg, var(--danger), #be123c);
}

.btn-sub {
    flex: 1;
    border: none;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
    height: 50px;
}

.btn-sub:hover {
    background: rgba(255, 255, 255, 0.05);
}

.log-container {
    height: 250px;
    /* Fixed height for log area */
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
    background: #000;
    border-radius: 10px;
    padding: 15px;
    border: 1px solid var(--border);
}

.log-container h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-sub);
}

.log-area {
    flex: 1;
    overflow-y: auto;
    font-family: 'Consolas', monospace;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.log-entry {
    color: var(--text-sub);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 2px;
}

.log-entry.success {
    color: var(--success);
    font-weight: bold;
}

.log-entry.error {
    color: var(--danger);
}

.log-entry.warning {
    color: var(--warning);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    border: 1px solid var(--border);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: var(--text-sub);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-info {
    background: var(--text-sub);
    color: #000;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* --- Collapsible Card Styles --- */

.card-header {
    display: flex;
    justify-content: flex-start;
    /* Icon next to text */
    align-items: center;
    gap: 10px;
    /* Space between text and icon */
    cursor: pointer;
    user-select: none;
    padding-bottom: 15px;
    transition: padding-bottom 0.3s ease;
}

.card:has(.card-body.collapsed) {
    gap: 0;
}

.card:has(.card-body.collapsed) .card-header {
    padding-bottom: 0;
}

.card-header h2 {
    margin-bottom: 0;
}

.toggle-icon {
    color: var(--text-sub);
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.card-body {
    overflow: hidden;
    transition: all 0.3s ease-out;
    max-height: 2000px;
    opacity: 1;
    display: flex;
    /* Layout for form groups */
    flex-direction: column;
    gap: 20px;
    /* Space between form groups */
    padding-top: 5px;
    /* Slight top padding */
}

.card-body.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
}