@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600&display=swap');

:root {
    --primary-color: #2563eb;
    /* Royal Blue - Clear & Trustworthy */
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    /* Very light slate/white */
    --card-bg: #ffffff;
    --text-main: #0f172a;
    /* Dark Slate */
    --text-muted: #64748b;
    /* Simplified Gradient - or just solid color. Let's stick to a very subtle reliable blue gradient or solid */
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius-lg: 16px;
    --radius-xl: 24px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll, handle inside app-container */
}

/* App Container for Mobile View */
.app-container {
    width: 100%;
    max-width: 480px;
    /* Mobile width constraint for desktop view */
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-color);
}

/* Header */
header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

/* Main Content Area */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 20px 20px;
    overflow-y: auto;
    gap: 20px;
}

/* Scanner Card */
.scanner-card {
    background: #f1f5f9;
    /* Light gray placeholder instead of black */
    border-radius: var(--radius-xl);
    overflow: hidden;
    position: relative;
    aspect-ratio: 1/1;
    /* Square scanner */
    width: 100%;
    box-shadow: var(--shadow-lg);
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
}

/* Show scanner when active */
body.scanning-mode .scanner-card {
    display: flex !important;
    margin-bottom: 20px;
}

body.scanning-mode #result {
    opacity: 0.3;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Hide other content when scanning? Optional. For now just show card. */

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    /* Hidden/invisible until active */
    transition: opacity 0.3s ease;
}

#video.active {
    opacity: 1;
}

/* Scan Overlay & Placeholder */
.scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    /* border: 2px solid rgba(255,255,255,0.1); Removed dark border */
    border-radius: var(--radius-xl);
}

.scan-guide {
    position: absolute;
    width: 60%;
    height: 60%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.2);
    /* Much softer dim */
}

/* Controls */
.controls {
    display: flex;
    gap: 12px;
    margin-top: auto;
}

button {
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 18px;
    /* Increased from 16px */
    padding: 20px;
    /* Larger touch target */
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

button:active {
    transform: scale(0.98);
}

#action {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.4);
}

#file-trigger {
    background: white;
    color: var(--text-main);
    border: 2px solid #e2e8f0;
}

/* List Controls */
.list-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0px;
    /* result top padding handles spacing if needed, or we adjust */
}

#sort-trigger {
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    height: auto;
    flex: initial;
    /* Don't stretch like main action buttons */
    box-shadow: none;
    width: auto;
}

#sort-trigger:active {
    background: #f1f5f9;
}

/* Results Area */
#result {
    min-height: 100px;
    padding-bottom: 80px;
    /* Space for debug/bottom content */
}

.place-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.place-item {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s, box-shadow 0.2s;
    border: 1px solid #e2e8f0;
    /* Light gray border */
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.place-item:active {
    background: #f1f5f9;
}

.place-icon {
    width: 44px;
    height: 44px;
    background: #eff6ff;
    border-radius: 12px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.place-icon.missing-coords {
    background: #fff1f2;
    color: #e11d48;
    cursor: pointer;
}

.place-icon.missing-coords:hover {
    background: #ffe4e6;
}

.place-icon.existing-coords {
    cursor: pointer;
}

.place-icon.existing-coords:hover {
    background: #dbeafe;
    /* Slightly darker blue tint than default eff6ff */
}

.place-info {
    flex: 1;
    overflow: hidden;
}

.place-name {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    /* Ensure container respects width */
}

/* New editable name span */
.editable-name {
    display: inline-block;
    max-width: 100%;
    /* Truncate if too long */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Minimum click area */
    min-width: 40px;
    /* Visual cue */
    cursor: pointer;
}

.editable-name:empty::before {
    content: "이름 없음";
    color: var(--text-muted);
    font-style: italic;
}

.editable-name:hover {
    text-decoration: underline;
}

.place-coords {
    font-size: 12px;
    color: var(--text-muted);
}

/* Debug Panel */
#debug {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #334155 !important;
    backdrop-filter: blur(10px);
    border-top: 1px solid #cbd5e1;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 480px !important;
    margin: 0 auto;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Hidden elements */
.g-hidden {
    display: none !important;
}