/* ===== Base Styles ===== */
body {
    font-family: 'Noto Sans JP', 'Inter', sans-serif;
}

/* ===== Period Selector Buttons ===== */
.period-btn {
    transition: all 0.15s;
}
.period-btn:hover {
    background: #f0fdf4 !important;
    border-color: #06C755 !important;
    color: #06C755 !important;
}
.period-btn:active {
    transform: scale(0.95);
}

/* ===== Card Container ===== */
.card-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
    padding: 20px;
    transition: box-shadow 0.2s;
}
.card-container:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.card-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
}

/* ===== Navigation Tabs ===== */
.nav-tab {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.nav-tab:hover {
    color: #374151;
    border-bottom-color: #d1d5db;
}
.nav-tab.active {
    color: #06C755;
    border-bottom-color: #06C755;
    font-weight: 600;
}
.nav-tab i {
    font-size: 0.7rem;
}
.nav-tab span {
    font-size: 0.75rem;
}

/* ===== Tab Content ===== */
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== KPI Cards ===== */
.kpi-card {
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
    padding: 1rem;
    transition: all 0.2s;
}
.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

/* ===== Ranking Bars ===== */
.rank-bar {
    position: relative;
    overflow: hidden;
    border-radius: 0.75rem;
    background-color: #f9fafb;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    transition: transform 0.2s;
}
.rank-bar:hover {
    transform: translateX(4px);
}
.rank-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-radius: 0.75rem;
    transition: all 0.7s;
    z-index: 0;
}
.rank-bar-content {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.rank-badge {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

/* ===== Advice Cards ===== */
.advice-card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
    padding: 1.25rem;
    transition: all 0.2s;
}
.advice-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-4px);
}
.advice-card.priority-high { border-left: 4px solid #FF6B6B; }
.advice-card.priority-medium { border-left: 4px solid #F4A261; }
.advice-card.priority-low { border-left: 4px solid #06C755; }

/* ===== Insight Cards ===== */
.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background-color: #f9fafb;
    transition: background 0.2s;
}
.insight-item:hover {
    background-color: #f3f4f6;
}
.insight-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
}

/* ===== Upload Status ===== */
.upload-success {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
    border-radius: 0.75rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.upload-error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 0.75rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Responsive: Large screens ===== */
@media (min-width: 1024px) {
    .kpi-card { padding: 1.25rem; }
    .nav-tab span { font-size: 0.85rem; }
    
    /* KPI Grid: 3 columns on large screens */
    #kpiGrid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    /* Overview charts 2-column layout */
    #overviewCharts1 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    #overviewCharts2 {
        grid-template-columns: 1fr 2fr !important;
    }
    
    /* Path analysis 2-column */
    #pathCharts {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Trend charts 2-column */
    #trendCharts {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Advice top grid 2-column */
    #adviceTopGrid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Advice cards 3-column */
    #adviceCards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 1280px) {
    #adviceCards {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ===== Responsive: Small screens ===== */
@media (max-width: 640px) {
    .kpi-card p[id^="kpi"]:first-of-type { font-size: 1.25rem; }
    .nav-tab { 
        padding: 0.5rem 0.6rem; 
        font-size: 0.7rem; 
    }
    .nav-tab span { font-size: 0.65rem; }
    .nav-tab i { font-size: 0.65rem; }
    .card-container { padding: 14px; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #c5c5c5; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* ===== Drop Zone Active ===== */
.drop-active {
    border-color: #4ade80 !important;
    background-color: #f0fdf4 !important;
}

/* ===== Buttons ensure clickable ===== */
button, [onclick], label[for], input[type="file"] + label {
    cursor: pointer;
}

/* iOS Safari: input要素のヒットエリア修正 */
input[type="password"],
input[type="text"],
input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    max-height: 44px;
    position: relative;
    z-index: 1;
}

/* ===== Print Styles ===== */
@media print {
    header, nav, footer, .nav-tab, button { display: none !important; }
    .tab-content { display: block !important; }
    .card-container { box-shadow: none !important; border: 1px solid #e5e7eb !important; break-inside: avoid; }
    body { background: white; }
}
