/* Universal Box Sizing & Font Smoothing */
html {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
*, *:before, *:after {
    box-sizing: inherit;
}

/* General Body and Font Styles */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f4f8;
    color: #334155; /* slate-700 */
    margin: 0;
}

/* Link to Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;900&display=swap');

/* Layout */
.container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
    max-width: 80rem;
}

@media (min-width: 768px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Header */
.brand-gradient {
    background: linear-gradient(to right, #0ea5e9, #2563eb);
}

header {
    color: white;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

header h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    margin: 0;
    font-size: clamp(1.25rem, 5vw, 1.875rem);
    min-width: 0;
    white-space: nowrap;
}

header p {
    color: #bae6fd; /* sky-200 */
}

.header-logo {
  width: 50px;
  height: auto;
}

/* Main Content & Flexbox Layout */
main {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.main-layout {
    display: flex;
    flex-direction: column; /* Stack on mobile */
    gap: 2rem;
}

@media (min-width: 1024px) {
    .main-layout {
        flex-direction: row; /* Side-by-side on desktop */
    }
}

.left-column {
    flex: 1; /* Takes up 1/3 of the space */
    display: grid;
}

.right-column {
    flex: 2; /* Takes up 2/3 of the space */
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.card {
    background-color: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    display: flex;
    flex-direction: column;
}

.left-column > .card {
  align-self: start;
}

/* Map Card */
.map-card {
    height: auto;
    overflow: hidden;
    min-height: 0; /* allow it to collapse to map size */
}

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Align items to the top to prevent stretching */
    gap: 1rem; /* Add gap for spacing */
    margin-bottom: 1rem;
}

.card-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    line-height: 1.2; /* Adjust line height for wrapping */
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0; /* Prevent buttons from shrinking */
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* JSON Viewer & Table Container */
.json-viewer, .table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.json-viewer {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
    background-color: #0b1220;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.75rem;
    display: block;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    /* critical: keep JSON unwrapped, scroll horizontally instead */
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
    /* prevent iOS Safari from boosting font-size on landscape after toggles */
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* Prevents content from squashing columns */
}

table th, table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}
table th {
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
}
td.key {
    font-family: monospace;
    color: #0369a1;
    word-break: break-word;
    width: 35%; /* fixed width for key column */
}
td.value {
    font-family: monospace;
    color: #475569;
    word-break: break-all;
}

/* Map */
#map {
    width: 100%;
    aspect-ratio: 1 / 1;  /* keep it a square */
    height: auto;
    min-height: 18rem;
    max-height: 32rem;
    border-radius: 0.75rem;
    overflow: hidden;
}

/* Buttons & Footer */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    background-color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}
.btn:hover {
    background-color: #f8fafc;
}
.btn-primary {
    background: linear-gradient(to right, #0ea5e9, #2563eb);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-weight: 700;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgb(59 130 246 / 0.2), 0 4px 6px -2px rgb(59 130 246 / 0.2);
}
.btn-primary:hover {
    background: linear-gradient(to right, #38bdf8, #3b82f6);
}
footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: #64748b;
    font-size: 0.875rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translate(-50%, 10rem);
    background-color: #1e293b;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out, visibility 0.3s;
    z-index: 1000;
}
.toast.active {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
}

/* Utility */
.hidden {
    display: none;
}

/* Prevent flex children from overflowing */
.left-column,
.right-column,
.card {
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 390px) {
  .header-logo { width: 28px; }
}

