/* styles.css - DBSDV Market Navigator */

:root {
    /* Theme Colors (Kaioshen Theme) */
    --bg-base: #fdf5f6;
    /* Very light pink background */
    --bg-grad-top: #ffebf0;
    /* Pinkish */
    --bg-grad-bottom: #eaffea;
    /* Greenish */
    --text-main: #333333;
    --text-muted: #777777;

    /* Accents */
    --primary: #ffd700;
    /* Yellow / Gold */
    --up-green: #2ecc71;
    /* Lime Green for rising */
    --down-pink: #ff4757;
    /* Pink/Red for falling */
    --neutral-gray: #a4b0be;
    /* Gray for no change */

    /* UI Elements */
    --card-bg: #ffffff;
    --border-color: #e1e8ed;
    --header-bg: #ffffff;
    --tab-bg: #ffffff;
    --tab-active: #ffeaa7;
    /* Soft yellow for active tab */

    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);

    /* Variables for frozen column */
    --first-col-width: 180px;
    /* Increased for image thumbnail */
    --bottom-nav-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: linear-gradient(135deg, var(--bg-grad-top) 0%, var(--bg-grad-bottom) 100%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(var(--bottom-nav-height) + 20px);
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

/* Utilities */
.text-lime {
    color: var(--up-green);
    font-weight: bold;
}

.text-pink {
    color: var(--down-pink);
    font-weight: bold;
}

.text-gray {
    color: var(--neutral-gray);
}

.text-right {
    text-align: right;
}

.text-link {
    color: #0984e3;
    text-decoration: underline;
    font-size: 0.85rem;
}

.hidden {
    display: none !important;
}

.margin-bottom {
    margin-bottom: 20px;
}

/* --- App Header --- */
.app-header {
    background: var(--header-bg);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-main);
}

.header-logo i {
    color: var(--primary);
    font-size: 1.4rem;
}

.beta-tag {
    background: var(--text-main);
    color: #fff;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-family: 'Noto Sans JP', sans-serif;
}

.icon-btn {
    font-size: 1.2rem;
    color: var(--text-main);
    padding: 8px;
}

/* Quick Search Bar */
.quick-search-bar {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #fff;
    padding: 10px 16px;
    box-shadow: var(--shadow-md);
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.quick-search-bar.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.quick-search-bar input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.9rem;
    outline: none;
}

.quick-search-bar input:focus {
    border-color: var(--primary);
}

.quick-search-bar button {
    background: var(--primary);
    color: #000;
    width: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- App Main & Views --- */
.app-main {
    padding: 16px;
}

.view-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Section Titles --- */
.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 24px 0 16px;
}

.section-title h2 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Home: Shortcuts --- */
.shortcut-banner {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.shortcut-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    min-width: 160px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.shortcut-item strong {
    font-size: 1rem;
    margin-bottom: 4px;
    z-index: 2;
}

.shortcut-item small {
    font-size: 0.75rem;
    color: var(--text-muted);
    z-index: 2;
    display: flex;
    justify-content: space-between;
}

.bubble {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    top: -20px;
    right: -20px;
    opacity: 0.2;
    z-index: 1;
}

.bubble-blue {
    background: #74b9ff;
}

.bubble-pink {
    background: #fd79a8;
}

/* Image Thumbnails */
.card-cell-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-thumb-sm {
    width: 35px;
    height: 50px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    background: #f1f2f6;
}

.list-item-thumb {
    width: 45px;
    height: 64px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    background: #f1f2f6;
    margin-right: 12px;
}

/* Rank Badges */
.rank-badge {
    display: inline-block;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.8rem;
    text-align: center;
}

.rank-SS {
    background: linear-gradient(135deg, #f1c40f, #e67e22);
    box-shadow: 0 0 8px rgba(241, 196, 15, 0.5);
}

.rank-S {
    background: #e74c3c;
}

.rank-A {
    background: #3498db;
}

.rank-B {
    background: #2ecc71;
}

.rank-C {
    background: #95a5a6;
}

/* --- List Items (Home/Ranking) --- */
.list-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.list-rank {
    font-family: 'Oswald', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    width: 30px;
    color: var(--text-muted);
}

.rank-1 {
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
    font-size: 1.4rem;
}

.rank-2 {
    color: #c0c0c0;
    font-size: 1.3rem;
}

.rank-3 {
    color: #cd7f32;
    font-size: 1.3rem;
}

.item-info {
    flex: 1;
    display: flex;
    align-items: center;
}

.item-info-text {
    flex: 1;
}

.item-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-price {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.price-val {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
}

.price-change {
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
}


/* --- List View: Filters --- */
.filter-accordion {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.accordion-header {
    width: 100%;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 0.95rem;
    background: #f8f9fa;
}

.filter-badge {
    background: var(--primary);
    color: #000;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
}

.toggle-icon {
    transition: transform 0.3s;
}

.filter-accordion.open .toggle-icon {
    transform: rotate(180deg);
}

.accordion-body {
    padding: 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.filter-accordion.open .accordion-body {
    padding: 16px;
    max-height: 500px;
    border-top: 1px solid var(--border-color);
}

.filter-group {
    margin-bottom: 15px;
}

.filter-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--text-muted);
}

.filter-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
}

.filter-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--primary);
    color: #000;
}

.btn-outline {
    border: 1px solid var(--border-color);
    background: #fff;
}

.btn-full {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    box-sizing: border-box;
}

.btn-outline:active {
    background: #f1f2f6;
}

/* --- Table View (Frozen Column) --- */
.table-container {
    width: 100%;
    overflow-x: auto;
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
}

.market-table {
    width: 100%;
    min-width: 600px;
    /* Minimum width to force scroll on small screens */
    border-collapse: collapse;
    font-size: 0.85rem;
}

.market-table th,
.market-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
    /* Prevent text wrapping in cells */
}

.market-table th {
    background: #f8f9fa;
    font-weight: 700;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Frozen Column Magic */
.frozen-col {
    position: sticky;
    left: 0;
    background: #fff;
    /* Needs solid background */
    z-index: 5;
    width: var(--first-col-width);
    border-right: 2px solid var(--border-color);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.02);
    /* Slight shadow to show depth */
}

.market-table th.frozen-col {
    z-index: 15;
    /* Header of frozen column needs to be highest */
    background: #f8f9fa;
}

.market-table tbody tr:hover td {
    background: #fafafa;
}

.market-table tbody tr:hover td.frozen-col {
    background: #fdfdfd;
}

/* Table cell specific styling */
.card-cell-name {
    font-weight: 700;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-cell-id {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.val-price {
    font-family: 'Oswald', sans-serif;
    font-size: 1rem;
    font-weight: 700;
}

.val-vol {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Badge for table row click */
.table-container tbody tr {
    cursor: pointer;
}


/* --- Ranking View Tabs --- */
.ranking-tabs {
    display: flex;
    background: var(--card-bg);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.r-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 8px;
    color: var(--text-muted);
}

.r-tab.active {
    background: var(--tab-active);
    color: var(--text-main);
}


/* --- Bottom Navigation --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--bottom-nav-height);
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    /* iOS safe area */
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    width: 25%;
    height: 100%;
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Card Detail Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    /* Drop up from bottom on mobile */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-base);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    padding: 24px 20px;
    overflow-y: auto;
    position: relative;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: #eee;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    font-size: 1.2rem;
    opacity: 0.8;
}

/* New Detail Elements */
.detail-main-img {
    width: 100%;
    max-width: 200px;
    /* Kept clean size */
    border-radius: 12px;
    margin: 0 auto 20px;
    display: block;
    box-shadow: var(--shadow-md);
    background: #f1f2f6;
    object-fit: contain;
}

.detail-header {
    margin-bottom: 20px;
    padding-right: 30px;
}

.detail-number {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.detail-name {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 8px;
}

.detail-badges {
    display: flex;
    gap: 8px;
}

.badge {
    background: #eee;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-dark {
    background: #333;
    color: #fff;
}

.detail-price-summary {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.price-main {
    text-align: center;
    margin-bottom: 15px;
    border-bottom: 1px dotted #ccc;
    padding-bottom: 10px;
}

.price-main .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.price-main .value {
    font-family: 'Oswald', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.price-main .value small {
    font-size: 1rem;
    font-family: 'Noto Sans JP', sans-serif;
    margin-left: 5px;
}

.price-sub {
    display: flex;
    justify-content: space-around;
}

.sub-item {
    text-align: center;
}

.sub-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sub-item .value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Oswald', sans-serif;
}

.status-alert {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--neutral-gray);
    text-align: center;
    background: #f5f6fa;
    padding: 5px;
    border-radius: 5px;
}

.detail-section {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.detail-section h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
}

.chart-container {
    width: 100%;
    height: 200px;
}

/* Voting Section */
.rank-display {
    margin-bottom: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.vote-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.vote-section {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.vote-btn {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.05);
    /* 3D effect */
    transition: all 0.2s;
}

.vote-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.vote-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Comments */
.comment-list {
    margin-bottom: 20px;
}

.comment-item {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.comment-author {
    font-weight: 700;
    color: var(--text-main);
}

.comment-text {
    font-size: 0.9rem;
}

.comment-form {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    outline: none;
}

.comment-form input:focus,
.comment-form textarea:focus {
    border-color: var(--primary);
}

.skill-box h4 {
    font-size: 0.95rem;
    margin-bottom: 5px;
    color: #0984e3;
}

.skill-box p {
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 10px;
}

.perfect-effect {
    background: #fff9e6;
    border: 1px dashed #f1c40f;
    padding: 10px;
    border-radius: 8px;
}

.perfect-label {
    display: inline-block;
    background: #f1c40f;
    color: #000;
    font-size: 0.7rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.perfect-effect p {
    margin-bottom: 0;
    font-weight: 500;
}

/* App Footer */
.app-footer {
    text-align: center;
    padding: 20px;
    font-size: 0.65rem;
    color: var(--text-muted);
}