/* style.css */
:root {
    --primary-color: #3b82f6;
    /* Modern Blue */
    --primary-dark: #2563eb;
    --background-color: #f1f5f9;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --danger-color: #ef4444;
    --success-color: #10b981;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
}

header {
    background: var(--surface-color);
    padding: 1rem 2rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
    letter-spacing: -0.025em;
}

h2 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 1.5rem;
}

h3 {
    margin-top: 0;
    color: var(--text-primary);
}

nav {
    display: flex;
    gap: 1rem;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

main {
    padding: 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-content.active {
    display: block;
}

/* Forms & Cards */
.form-card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    margin-bottom: 2rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: background-color 0.2s, transform 0.1s;
}

.primary-btn:hover {
    background-color: var(--primary-dark);
}

.primary-btn:active {
    transform: scale(0.98);
}

.primary-btn:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
}

button[onclick^="delete"] {
    background-color: white;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

button[onclick^="delete"]:hover {
    background-color: var(--danger-color);
    color: white;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

tr:last-child td {
    border-bottom: none;
}

/* Dashboard Stats */
#stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    text-align: center;
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-card p {
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
}

/* Planning layout */
.planning-layout {
    display: flex;
    gap: 1.5rem;
    height: 80vh;
}

.planning-controls {
    flex: 3;
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.map-container {
    flex: 2;
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    overflow: hidden;
    min-width: 300px;
}

#map {
    width: 100%;
    height: 100%;
}

/* Route Results */
#route-results {
    margin-top: 2rem;
}

.route-card {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.route-card h4 {
    margin: 0 0 0.5rem 0;
}

.route-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.tour-table-container {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.tour-table {
    width: 100%;
    margin-bottom: 0;
    font-size: 0.85rem;
    border-collapse: separate;
    border-spacing: 0;
    /* Removed table-layout: fixed to allow resizing */
}

.tour-table th {
    position: relative;
    user-select: none;
}

.tour-table th,
.tour-table td {
    padding: 0.5rem;
    min-width: 50px;
    white-space: nowrap;
}

.resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    cursor: col-resize;
    user-select: none;
    height: 100%;
    z-index: 10;
}

.resize-handle:hover {
    background-color: var(--primary-color);
}

.date-header {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    /* Clickable for collapse */
    user-select: none;
    transition: background 0.2s;
}

.date-header:hover {
    background: #f1f5f9;
}

.date-header::after {
    content: '▼';
    font-size: 0.8rem;
    margin-left: 1rem;
    transition: transform 0.2s;
}

.date-group.collapsed .date-header::after {
    transform: rotate(-90deg);
}

.date-group.collapsed table {
    display: none;
}

.route-stats span {
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

details summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--primary-color);
    outline: none;
}

details ol {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

details li {
    margin-bottom: 0.25rem;
}
/* --- Auth & Overlay --- */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000;
}
.login-card {
    background: var(--surface-color);
    padding: 2.5rem; border-radius: 12px;
    width: 100%; max-width: 400px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
}
.login-card h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center;
}
#auth-toggle {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}
#auth-toggle a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
.error-msg {
    color: #ef4444;
    background: #fef2f2;
    padding: 0.75rem;
    border-radius: 6px;
    margin-top: 1rem;
    font-size: 0.9rem;
    text-align: center;
}
#btn-logout {
    margin-left: auto;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}
nav {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
}
.secondary-btn {
    background: #e2e8f0;
    color: #475569;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}
.secondary-btn:hover {
    background: #cbd5e1;
}
