body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    background-color: #f8f9fa;
    color: #212529;
}

.header-container {
    display: grid;
    grid-template-columns: 1fr minmax(300px, 960px) 1fr;
    grid-template-rows: auto auto;
    row-gap: 6px;
    align-items: center;
    padding: 20px 40px;
    background-color: #fff;
    margin: 0 0 30px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Remove wrapper styles since we're not using it anymore */

.header-flag {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-logos {
    margin-left: 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
}

.header-logo {
    height: 120px;
    width: auto;
    object-fit: contain;
}

.flag-logo {
    height: 120px;
    width: auto;
    object-fit: contain;
}

h1 {
    margin: 0;
    text-align: center;
    grid-column: 2;
    grid-row: 1;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.main-description {
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 0 auto;
    padding: 0;
    color: #555;
    text-align: center;
    width: 95%;
    max-width: none;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.table-container {
    width: 90%;
    margin: 0 auto 10px auto; /* Reduced bottom margin */
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 100px); /* Adjust based on header + filter height */
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

/* Allow text wrapping for specific fields */
td[data-label="Profile"],
td[data-label="プロファイル"] {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 350px;
    min-width: 300px;
}

td[data-label="Main job categories sent to Japan"],
td[data-label="主な職種"] {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 350px;
    min-width: 200px;
}

/* Style for job categories with line breaks */
td[data-label="Main job categories sent to Japan"],
td[data-label="主な職種"] {
    line-height: 1.6;
}

td[data-label="Address"],
td[data-label="住所"],
td[data-label="Website"],
td[data-label="Website"],
td[data-label="Facebook page"],
td[data-label="Facebookページ"] {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 300px;
    min-width: 250px;
}

td[data-label="Website of the language school"],
td[data-label="併設日本語学校webサイト"],
td[data-label="FB of the language school"],
td[data-label="併設日本語学校Facebook"] {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 300px;
    min-width: 250px;
}

/* Wrap text for "Nos. sent to Japan & their main jobs" and "Name of the licensee" */
td[data-label="Nos. sent to Japan & their main jobs"],
td[data-label="送り出し数と主な職種"],
td[data-label="Name of the licensee"],
td[data-label="ライセンス保有者"] {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 250px;
    min-width: 200px;
    line-height: 1.6;
}

/* Wrap text for "Office in Japan if any" */
td[data-label="Office in Japan if any"],
td[data-label="日本の事務所（あれば）"] {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 250px;
    min-width: 200px;
    line-height: 1.6;
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

th:first-child,
td:first-child {
    position: sticky;
    left: 0;
    background-color: #fff;
    z-index: 1;
}

thead th:first-child {
    z-index: 3; /* Higher z-index for the first column header to appear above regular headers */
}

thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    z-index: 2;
    position: sticky;
    top: 0;
    border-bottom: 2px solid #dee2e6; /* Stronger border to maintain visual separation */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Add shadow to make the header appear elevated */
}

/* Zebra stripes for table rows */
tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

tbody tr:nth-child(even) td:first-child {
    background-color: #f8f9fa;
}

thead th:first-child {
    background-color: #f8f9fa;
}

tbody tr:hover {
    background-color: #e9ecef !important;
}

tbody tr:hover td:first-child {
    background-color: #e9ecef !important;
}

.company-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
    vertical-align: middle;
}

.company-cell {
    display: flex;
    align-items: center;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.filter-container {
    width: 90%;
    margin: 0 auto 20px auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.filter-container form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-container select,
.filter-container input,
.filter-container button {
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    font-size: 16px;
    height: 40px; /* Set a fixed height */
    box-sizing: border-box; /* Ensure padding is included in height */
}

.filter-container button,
.clear-filter {
    display: inline-flex; /* Use inline-flex for alignment */
    align-items: center; /* Vertically center text */
    justify-content: center; /* Horizontally center text */
}

.filter-container button {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    cursor: pointer;
}

.filter-container button:hover {
    background-color: #0056b3;
}

.clear-filter {
    padding: 5px 15px;
    background-color: #6c757d;
    color: white;
    border-radius: 5px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    height: 40px; /* Set a fixed height */
    box-sizing: border-box; /* Ensure padding is included in height */
}

.clear-filter:hover {
    background-color: #5a6268;
    text-decoration: none;
}

.scroll-instruction {
    display: inline-block;
    margin-left: 15px;
    font-size: 14px;
    color: #6c757d;
    font-style: italic;
    vertical-align: middle;
}

.sort-icon {
    font-size: 10px;
    margin-left: 5px;
}

.print-button {
    display: block;
    padding: 8px 15px;
    margin-top: 10px;
    background-color: #17a2b8;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
}

.print-button:hover {
    background-color: #138496;
    text-decoration: none;
}

.page-footer {
    width: 90%;
    margin: 0px auto 0 auto; /* Reduced top margin to decrease gap */
    padding: 20px 0;
}

.footer-content {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.copyright {
    color: #666;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 20px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

/* Responsive Design */
@media screen and (max-width: 1360px) {

    .header-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 15px 20px;
        gap: 15px;
        position: relative;
    }

    /* Position logos on the left */
    .header-logos {
        display: flex;
        align-items: center;
        gap: 15px;
        margin: 0;
        align-self: flex-start;
    }

    /* Position flag at the right corner */
    .header-flag {
        position: absolute;
        top: 15px;
        right: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin: 0;
    }
    .header-logo {
        height: 60px;
        width: auto;
        object-fit: contain;
    }

    .flag-logo {
        height: 60px;
        width: auto;
        object-fit: contain;
    }

    h1 {
        text-align: center;
        margin: 0;
        position: static;
        transform: none;
        align-self: center;
        width: 80%;
    }
    .main-description {
        position: static;
        transform: none;
        width: 95%;
        max-width: 95%;
        text-align: center;
        align-self: center;
        padding: 0;
    }
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    body {
        background: #f8f9fa !important;
        min-height: 100vh;
        overflow-x: hidden; /* Prevent horizontal scroll */
        margin: 0;
        padding: 0;
    }
    
    .header-container {
        padding: 15px 10px !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box;
        position: relative;
    }
    
    /* Position logos on the left */
    .header-logos {
        display: flex;
        align-items: center;
        gap: 15px;
        margin: 0 !important;
        align-self: flex-start;
    }

    /* Position flag at the right corner */
    .header-flag {
        position: absolute;
        top: 15px;
        right: 10px;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin: 0 !important;
    }
    
    /* Adjust print button for mobile */
    .print-button {
        font-size: 0.8rem;
        padding: 5px 10px;
        margin-top: 5px;
    }
    
    .table-container {
        border-radius: 0;
        box-shadow: none;
        width: 100% !important;
        background: #f8f9fa !important;
        overflow-x: hidden; /* Remove horizontal scroll */
        margin: 0 !important; /* Ensure no extra margins */
        padding: 0 !important; /* Remove padding to eliminate margins */
        box-sizing: border-box;
    }
    
    /* Ensure all elements use full width */
    * {
        max-width: 100% !important;
        box-sizing: border-box;
    }
    
    /* Remove any potential margins from main elements */
    .main-description,
    h1,
    .filter-container {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    tbody {
        display: grid;
        grid-template-columns: 1fr; /* Single column for mobile */
        gap: 15px;
        width: 100%;
        padding: 15px; /* Add padding to tbody instead of container */
        margin: 0;
        box-sizing: border-box;
    }

    table {
        border: 0;
        white-space: normal;
    }

    thead {
        display: none; /* Hide table headers on mobile */
    }

    tr {
        border: 1px solid #ddd;
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 4px 16px rgba(0,0,0,0.07);
        overflow: hidden;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        border-bottom: 1px dotted #ccc;
        padding: 10px 15px;
        background-color: #fff;
        word-wrap: break-word;
        overflow-wrap: break-word;
        width: 100%;
        box-sizing: border-box;
    }

    td:before {
        content: attr(data-label);
        font-weight: bold;
        text-align: left;
        padding-right: 1em;
    }

    td:last-child {
        border-bottom: 0;
    }

    th:first-child, td:first-child {
        position: static;
        background-color: transparent;
    }
    
    .company-cell {
        display: flex; /* Changed to flex for better alignment */
        align-items: center;
        text-align: left;
        padding: 15px;
        border-bottom: 1px solid #ddd;
        background-color: #e9ecef; /* Added header color for the tile */
    }

    td.company-cell:before {
        display: none; /* Hide data-label for the main company cell */
    }

    .filter-container {
        width: 100%;
        margin: 0 auto 20px auto;
        padding: 15px;
        box-sizing: border-box;
    }
    
    .filter-container form {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .clear-filter {
        display: block;
        width: 100%;
        /* max-width: 200px; */
        margin: 8px auto 0 auto;
        text-align: center;
    }

    .scroll-instruction {
        display: block;
        margin: 8px auto 0 auto;
        text-align: center;
        font-size: 13px;
        width: 100%;
    }

    .print-button {
        bottom: 10px;
        left: 10px;
    }

    .header-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 15px 20px;
        gap: 15px;
    }


    .header-logos {
        margin-left: 0px;
        gap: 15px;
        align-self: flex-start;
    }

    .header-logo {
        height: 40px;
        width: auto;
        object-fit: contain;
    }

    .flag-logo {
        height: 40px;
        width: auto;
        object-fit: contain;
    }

    h1 {
        text-align: center;
        margin: 15px 0 20px 0; /* Add top margin to avoid PRINT button overlap */
        position: static;
        transform: none;
        align-self: center;
        width: 100%;
    }
    .main-description {
        position: static;
        transform: none;
        width: 100%;
        max-width: 100%;
        text-align: center;
    }
    
    .page-footer {
        width: 100%;
        margin: 20px auto 0 auto;
        padding: 15px;
        box-sizing: border-box;
    }
    
    .footer-content {
        justify-content: flex-end;
    }
    
    .copyright {
        font-size: 12px;
        padding: 8px 15px;
    }
    
    /* Language selector alignment */
    div[style*="text-align: center"] {
        width: 100%;
        padding: 0 15px;
        box-sizing: border-box;
        margin-bottom: 20px;
    }
    
    /* Ensure all direct children of body are properly contained */
    body > div, body > a {
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* Extra small mobile devices */
@media screen and (max-width: 480px) {
    .header-logo {
        height: 30px;
        width: auto;
        object-fit: contain;
    }
    
    .flag-logo {
        height: 30px;
        width: auto;
        object-fit: contain;
    }
} 