/* Global Styles */
:root {
    --primary-color: #2fb4d6;
    /* Light Blue similar to Shironeko UI */
    --accent-color: #f7d643;
    /* Gold/Yellow for accents */
    --bg-color: #f0f8ff;
    /* Very light blue background */
    --panel-bg: #ffffff;
    --text-color: #333333;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --header-height: 50px;
    /* Fixed header for table */
    --font-heading: 'M PLUS Rounded 1c', sans-serif;
    --font-body: 'Sawarabi Gothic', sans-serif;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-y: scroll;
    /* Always show scrollbar to prevent shift */
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.main-header {
    text-align: center;
    padding: 20px 0;
    margin-bottom: 20px;
}

.main-header h1 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin: 0;
    font-size: 2rem;
    text-shadow: 1px 1px 0px #fff, 2px 2px 0px rgba(0, 0, 0, 0.1);
}

/* Panels */
.search-panel,
.results-panel {
    background: var(--panel-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(47, 180, 214, 0.2);
}

.search-panel-header h2 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-top: 0;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
    padding-bottom: 5px;
}

/* Search Grid */
.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(47, 180, 214, 0.2);
}

.search-status {
    text-align: right;
    font-weight: bold;
    color: var(--primary-color);
}

/* Results Table */
.table-container {
    overflow-x: auto;
    max-height: 60vh;
    /* Fixed height for vertical scrolling */
    position: relative;
    border-radius: 8px;
    border: 1px solid #eee;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
    /* Ensure table doesn't get too squished */
}

thead {
    position: sticky;
    top: 0;
    background-color: var(--primary-color);
    z-index: 10;
}

th {
    color: white;
    padding: 12px 10px;
    text-align: left;
    font-weight: bold;
    white-space: nowrap;
    font-family: var(--font-heading);
}

td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
    color: #444;
}

/* Specific Columns */
.col-name {
    white-space: nowrap;
    width: 1%;
    /* Trick to shrink fit content */
}

.col-cv {
    width: 6em;
    min-width: 6em;
    max-width: 6em;
}

/* .col-cv removed to allow wrapping */

tbody tr:hover {
    background-color: #f9fcff;
}

/* Icon columns */
.col-icon-main {
    width: 60px;
    text-align: center;
    padding: 5px;
}

.char-icon {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.col-icon {
    width: 60px;
    text-align: center;
}

.icon-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.row-icon {
    /* Sizing controlled by JS onload (1/6 scale) */
    vertical-align: middle;
    margin-right: 5px;
    width: auto;
    height: auto;
    object-fit: contain;
    /* background-color: #eee; Remove placeholder bg as it looks bad with transparent pngs if any */
    border-radius: 4px;
    /* transition: transform 0.2s; */
}

.icon-text {
    font-size: 0.75rem;
    color: #666;
}

.col-gc {
    text-align: center;
    font-weight: bold;
    width: 7.5em;
    /* Fits "パラメータ調整" (7 chars) then wraps */
    min-width: 7.5em;
    max-width: 7.5em;
    word-break: break-all;
    white-space: normal;
    /* Override global th nowrap */
    line-height: 1.2;
    vertical-align: middle;
}

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

.loading-msg,
.error-msg,
.no-result {
    text-align: center;
    padding: 20px;
    font-weight: bold;
    color: #777;
}

.error-msg {
    color: #d9534f;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 5px;
    }

    .main-header h1 {
        font-size: 1.5rem;
    }

    .search-grid {
        grid-template-columns: 1fr;
        /* Stack vertically on mobile */
    }

    /* Hide less important columns on mobile if needed, or allow scroll */
    .desktop-only {
        display: none;
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    background: var(--panel-bg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #eee;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Skill Popup UI */
.popup-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f8ff;
    display: flex;
    align-items: center;
    gap: 15px;
}

.popup-char-icon {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    border: 2px solid var(--primary-color);
}

.popup-title h3 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--primary-color);
    font-family: var(--font-heading);
}

.popup-title p {
    margin: 5px 0 0;
    font-size: 0.9rem;
    color: #888;
}

/* Toggle Switch */
.class-toggle {
    display: flex;
    background: #eee;
    padding: 4px;
    border-radius: 50px;
    margin-bottom: 20px;
}

.toggle-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 8px 15px;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-heading);
}

.toggle-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-btn:not(.active) {
    color: #777;
}

.toggle-btn:not(.active):hover {
    background: #e5e5e5;
}

/* Mobile Toggle Layout: ensure they are side-by-side */

/* Skill Items */
.skill-section {
    margin-bottom: 15px;
}

.skill-label {
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    background: var(--primary-color);
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 5px;
}

.skill-name {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 4px;
    color: #333;
}

.skill-desc {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #555;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Rune Drive Decoration */
.skill-section.rune-drive .skill-label {
    background: #e91e63;
}
