/* JPI - Japan Property Intelligence */

:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --accent-primary: #4f46e5;
    --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 6px;
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    min-width: 36px;
    padding: 0 0.4rem;
    border-radius: 9px;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #ffffff;
    background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 100%);
    box-shadow: var(--shadow-sm);
}

.logo-image {
    height: 56px;
    width: auto;
    object-fit: contain;
}

.logo-wide {
    width: 280px;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.nav-link.active {
    color: var(--accent-primary);
    background: rgba(79, 70, 229, 0.1);
    font-weight: 600;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
}

.stats {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.stat-item {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
}

.filter-group {
    display: flex;
    gap: 0.75rem;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.checkbox input {
    width: 16px;
    height: 16px;
}

/* Form Elements */
.input,
.select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.input:focus,
.select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.input::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

/* Listings Grid */
.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Property Card */
.property-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.property-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.property-card.color-green {
    border-left: 5px solid var(--success);
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.08) 0%, var(--bg-card) 20%);
}

.property-card.color-yellow {
    border-left: 5px solid var(--warning);
    background: linear-gradient(90deg, rgba(234, 179, 8, 0.08) 0%, var(--bg-card) 20%);
}

.property-card.color-red {
    border-left: 5px solid var(--danger);
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.08) 0%, var(--bg-card) 20%);
}

.card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--bg-primary);
}

.card-image-placeholder {
    display: none;
}

.card-body {
    padding: 1.25rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 0.75rem;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.meta-item {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.card-location {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.card-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.badge-new {
    background: var(--success);
    color: white;
}

/* Color indicator in card */
.card-color-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.page-info {
    color: var(--text-secondary);
}

/* Listings List */
.listings-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-row,
.list-header {
    display: grid;
    grid-template-columns: 140px 120px 140px 140px 1fr 40px;
    gap: 1rem;
    align-items: center;
    padding: 0.85rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.list-header {
    background: var(--bg-primary);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.list-row {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.list-row:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.list-cell-title {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.list-title {
    font-weight: 600;
    color: var(--text-primary);
}

.list-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.list-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.list-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.badge-new {
    background: var(--success);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
}

.list-arrow {
    font-size: 1rem;
    color: var(--text-muted);
}

.list-detail {
    display: none;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.list-detail.active {
    display: block;
}

.list-row.color-green {
    border-color: rgba(34, 197, 94, 0.5);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

.list-row.color-yellow {
    border-color: rgba(234, 179, 8, 0.5);
    box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.15);
}

.list-row.color-red {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

@media (max-width: 900px) {
    .list-row,
    .list-header {
        grid-template-columns: 120px 1fr 120px;
        grid-auto-rows: auto;
    }

    .list-cell-hide-mobile {
        display: none;
    }
}

/* Card Section */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

/* Form */
.source-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group .input {
    width: 100%;
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Sources List */
.sources-list {
    margin-top: 2rem;
}

.sources-list h2 {
    margin-bottom: 1rem;
}

.source-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.source-card:hover {
    border-color: var(--accent-primary);
}

.source-info {
    flex: 1;
    min-width: 0;
}

.source-info h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.source-region {
    font-size: 0.875rem;
    color: var(--accent-primary);
    font-weight: 500;
}

.source-url {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.25rem;
}

.source-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
    align-items: flex-start;
}

.action-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.action-help {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.2;
    max-width: 140px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.progress {
    width: 100%;
    height: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-primary);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.jp-tracker {
    position: relative;
    margin-top: 1rem;
    height: 240px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(84, 78, 255, 0.04), rgba(84, 78, 255, 0.01));
    overflow: hidden;
}

.jp-map-host {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jp-map-real {
    width: 100%;
    height: 100%;
}

.jp-map-real g.prefecture {
    transition: fill 0.22s ease, stroke 0.22s ease;
    fill: #efeff6 !important;
    stroke: #c8d2eb !important;
    stroke-width: 1 !important;
}

.jp-map-real g.prefecture.jp-active {
    fill: #5e5bff !important;
    stroke: #3b38d9 !important;
    filter: drop-shadow(0 0 5px rgba(94, 91, 255, 0.45));
}

.jp-source-label {
    position: absolute;
    left: 10px;
    bottom: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.9);
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

#modal-body {
    padding: 2rem;
}

.modal-header {
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.modal-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-item {
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
}

.modal-item-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.modal-item-value {
    font-size: 1rem;
    font-weight: 600;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* Annotation Controls */
.annotation-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-primary);
    border-radius: 12px;
    margin-top: 1.5rem;
}

.color-buttons {
    display: flex;
    gap: 0.5rem;
}

.color-btn {
    width: 36px;
    height: 36px;
    border: 3px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px white;
}

.color-btn.green {
    background: var(--success);
}

.color-btn.yellow {
    background: var(--warning);
}

.color-btn.red {
    background: var(--danger);
}

.color-btn.none {
    background: var(--bg-card);
    border: 2px dashed var(--text-muted);
}

.notes-input {
    flex: 1;
    min-width: 200px;
}

.notes-input textarea {
    width: 100%;
    min-height: 80px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-primary);
    resize: vertical;
    font-family: inherit;
}

.notes-input textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Status Select */
.status-select {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.status-option {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: capitalize;
}

.status-option:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.status-option.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Loading */
.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

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

    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .controls {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .input,
    .select {
        width: 100%;
    }

    .listings-grid {
        grid-template-columns: 1fr;
    }

    .modal-grid {
        grid-template-columns: 1fr;
    }

    .source-card {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .source-actions {
        margin-left: 0;
        width: 100%;
    }

    .source-actions .btn {
        flex: 1;
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}
