/* Apple Style Theme */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

:root {
    --apple-blue: #007aff;
    --apple-light-gray: #f5f5f7;
    --apple-medium-gray: #e5e5ea;
    --apple-dark-gray: #8a8a8e;
    --apple-text-primary: #1d1d1f;
    --apple-text-secondary: #6e6e73;
    --apple-card-background: rgba(255, 255, 255, 0.8);
    --apple-border-color: rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Roboto", "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--apple-light-gray);
    color: var(--apple-text-primary);
}

a {
    color: var(--apple-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Header Styles */
.header {
    text-align: center;
    padding: 40px 0;
}

.header h1 {
    font-size: 32px;
    font-weight: 600;
    margin: 0;
}

.header h2 {
    font-size: 20px;
    margin: 10px 0 0;
    color: var(--apple-text-secondary);
    font-weight: 400;
}

.header h1 a, .header h2 a {
    color: inherit;
    text-decoration: none;
}

/* --- FIX: Restored .db-card to this general rule --- */
.card, .db-card {
    background: var(--apple-card-background);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--apple-border-color);
    border-radius: 18px;
    padding: 28px;
    margin-bottom: 28px;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.card:hover, .db-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
}

/* --- Collapse animation for Search Panel on SSE.html --- */
#search-panel {
    overflow: hidden;
    transition: max-height 0.5s ease-in-out, padding-top 0.5s ease-in-out, padding-bottom 0.5s ease-in-out, margin-bottom 0.5s ease-in-out, border 0.5s ease-in-out;
    max-height: 2000px; /* A large enough height */
}

#search-panel.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    border-width: 0;
}

/* --- Styling for index.html Grid --- */
.db-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 28px;
    margin-top: 20px;
}

.db-card {
    text-align: center;
    text-decoration: none;
    color: var(--apple-text-primary);
}

.db-card .db-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--apple-blue);
}

.db-card .db-status {
    font-size: 15px;
    color: var(--apple-dark-gray);
    margin-top: 8px;
}


/* --- Form Styling for SSE.html --- */
.section-title {
    font-size: 22px;
    font-weight: 500;
    margin-top: 0;
    margin-bottom: 24px;
    color: var(--apple-text-primary);
}

.form-group-wide {
    display: flex;
    align-items: center;
    gap: 16px;
}
.form-group-wide label {
    flex-shrink: 0;
    font-weight: 500;
}
.form-group-wide input {
    flex-grow: 1;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 16px 24px;
}

.form-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.form-group label {
    flex-basis: 120px;
    flex-shrink: 0;
    text-align: right;
    margin-right: 8px;
    font-weight: 500;
    font-size: 15px;
    color: var(--apple-text-primary);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.unit {
    font-size: 14px;
    color: var(--apple-text-secondary);
    flex-basis: 80px;
    flex-shrink: 0;
}

input[type="text"],
input[type="number"] {
    background-color: #f0f0f5;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 15px;
    font-family: inherit;
    color: var(--apple-text-primary);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

input[type="number"] {
    width: 90px;
    text-align: center;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--apple-blue);
    background-color: #fff;
}

button[type="submit"] {
    display: block;
    width: auto;
    min-width: 120px;
    padding: 12px 24px;
    font-size: 17px;
    font-weight: 500;
    color: #fff;
    background-color: var(--apple-blue);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin: 32px auto 0;
}

button[type="submit"]:hover {
    background-color: #0056b3;
}

.form-divider {
    border: none;
    height: 1px;
    background-color: var(--apple-medium-gray);
    margin: 28px 0;
}

/* --- Toggle Button Styling for SSE.html --- */
.toggle-container {
    text-align: center;
    margin-bottom: 28px;
}

#toggle-search-button {
    font-family: inherit;
    background-color: #e9e9ed;
    color: var(--apple-text-primary);
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

#toggle-search-button:hover {
    background-color: #dcdce1;
}


/* --- Results Table Styling for SSE.html --- */
#results-container table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 15px;
}

#results-container th, 
#results-container td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--apple-medium-gray);
}

#results-container th {
    font-weight: 500;
    color: var(--apple-text-secondary);
}

#results-container tbody tr:last-child td {
    border-bottom: none;
}

#results-container tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto; /* This is the key: enables horizontal scrolling */
    -webkit-overflow-scrolling: touch; /* Improves scrolling experience on iOS */
}

#results-container table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 15px;
}

#results-container th, 
#results-container td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--apple-medium-gray);
    white-space: nowrap; /* --- ADD THIS LINE --- */
}

#results-container th {
    font-weight: 500;
    color: var(--apple-text-secondary);
}

/* --- Pagination Styling for SSE.html --- */
#pagination-container {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: -4px; /* Adjust to align better with the card */
}

#pagination-container button {
    font-family: inherit;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

#pagination-container button:hover:not([disabled]) {
    background-color: rgba(0, 0, 0, 0.05);
}

#pagination-container button.active {
    background-color: var(--apple-blue);
    color: #fff;
    border-color: var(--apple-blue);
    font-weight: 500;
}

#pagination-container button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

#pagination-container button[disabled]:hover {
    background-color: transparent;
}