/* Resort Mapper PWA - Mobile-First Styles */

:root {
    --primary: #0D47A1;
    --primary-dark: #002171;
    --primary-light: #5472d3;
    --secondary: #455A64;
    --accent: #FF6F00;
    --success: #4CAF50;
    --warning: #FF9800;
    --error: #F44336;
    --background: #F5F5F5;
    --surface: #FFFFFF;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border: #E0E0E0;
    --shadow: rgba(0, 0, 0, 0.1);
    --nav-height: 60px;
    --header-height: 56px;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* Screens */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    overflow: hidden;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Login Screen */
#screen-login {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-logo {
    margin-bottom: 40px;
    color: white;
}

.logo-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 14px;
    opacity: 0.8;
}

.login-form {
    background: var(--surface);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--primary);
}

.login-footer {
    margin-top: 24px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.error-text {
    color: var(--error);
    font-size: 14px;
    margin-top: 12px;
}

.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-user-select: none;
    user-select: none;
}

.btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--border);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: rgba(13, 71, 161, 0.1);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 18px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-round {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    padding: 0;
}

.btn-round svg {
    width: 32px;
    height: 32px;
}

.icon-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
}

.icon-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: var(--error);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* App Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    padding-top: var(--safe-area-top);
    background: var(--primary);
    color: white;
}

.app-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 4px;
}

.header-actions .icon-btn {
    color: white;
}

/* Screen Header */
.screen-header {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--header-height);
    padding: 0 16px;
    padding-top: var(--safe-area-top);
    background: var(--primary);
    color: white;
}

.screen-header h2 {
    flex: 1;
    font-size: 20px;
    font-weight: 500;
}

.screen-header .icon-btn {
    color: white;
    margin-left: -8px;
}

.step-indicator {
    font-size: 14px;
    opacity: 0.8;
}

/* Main Content */
.app-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-content {
    display: none;
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 16px);
}

.tab-content.active {
    display: block;
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    height: var(--nav-height);
    padding-bottom: var(--safe-area-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px var(--shadow);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.nav-item.active {
    color: var(--primary);
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.btn-new-entry {
    margin-bottom: 4px;
}

.stats-row {
    display: flex;
    gap: 12px;
}

.stat-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.stat-pending .stat-value {
    color: var(--warning);
}

/* Lookup Section */
.lookup-section {
    background: var(--surface);
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.lookup-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.lookup-input-group {
    display: flex;
    gap: 8px;
}

.lookup-input-group input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
    text-transform: uppercase;
}

.lookup-input-group input:focus {
    border-color: var(--primary);
}

.lookup-input-group .btn {
    padding: 12px;
}

.lookup-input-group .btn svg {
    width: 24px;
    height: 24px;
}

/* Recent Section */
.recent-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

/* Entries List */
.entries-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.entry-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
}

.entry-card:active {
    transform: scale(0.98);
}

.entry-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background: var(--border);
    object-fit: cover;
}

.entry-info {
    flex: 1;
    min-width: 0;
}

.entry-id {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

.entry-resort {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.entry-status {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.entry-status.pending {
    background: rgba(255, 152, 0, 0.1);
    color: var(--warning);
}

.entry-status.completed {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success);
}

.entry-status.failed {
    background: rgba(244, 67, 54, 0.1);
    color: var(--error);
}

.entry-status svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    width: 64px;
    height: 64px;
    fill: var(--border);
    margin-bottom: 16px;
}

.empty-icon.error {
    fill: var(--error);
}

/* Wizard */
.wizard-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.wizard-step {
    display: none;
}

.wizard-step.active {
    display: block;
}

.wizard-step h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.step-hint {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.wizard-footer {
    display: flex;
    gap: 12px;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-area-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.wizard-footer .btn {
    flex: 1;
}

/* Selection List */
.search-box {
    margin-bottom: 16px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
}

.search-box input:focus {
    border-color: var(--primary);
}

.selection-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.selection-item {
    padding: 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.selection-item:hover {
    border-color: var(--primary-light);
}

.selection-item.selected {
    border-color: var(--primary);
    background: rgba(13, 71, 161, 0.05);
}

.selection-item-title {
    font-size: 16px;
    font-weight: 500;
}

.selection-item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Photo Grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--border);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.photo-item .remove-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.camera-controls {
    display: flex;
    justify-content: center;
}

/* Radio Group (Sign Install Step) */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-option:hover {
    border-color: var(--primary-light);
}

.radio-option input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.radio-option input[type="radio"]:checked + .radio-label {
    color: var(--primary);
}

.radio-option:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: rgba(13, 71, 161, 0.05);
}

.radio-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.radio-title {
    font-size: 16px;
    font-weight: 500;
}

.radio-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Full Width Button */
.btn-full {
    width: 100%;
    margin-top: 12px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: var(--surface);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Location Card */
.location-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 16px;
}

.location-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 71, 161, 0.1);
    border-radius: 50%;
}

.location-icon svg {
    width: 28px;
    height: 28px;
    fill: var(--primary);
}

.location-info {
    flex: 1;
}

.location-info p {
    margin: 0;
}

.coords {
    font-family: monospace;
    font-size: 14px;
}

.accuracy {
    font-size: 12px;
    color: var(--text-secondary);
}

.accuracy.good {
    color: var(--success);
}

.accuracy.fair {
    color: var(--warning);
}

.accuracy.poor {
    color: var(--error);
}

.mini-map {
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
}

/* Review Card */
.review-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px var(--shadow);
}

.review-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.review-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.review-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.review-value {
    font-size: 16px;
    margin-top: 4px;
}

.review-photos {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    overflow-x: auto;
}

.review-photos img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
}

/* Lookup Screen */
.lookup-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.lookup-map {
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.lookup-details h3 {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 12px;
}

.photo-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.photo-scroll img {
    width: 120px;
    height: 90px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-item {
    background: var(--background);
    padding: 12px;
    border-radius: 8px;
}

.detail-item label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.detail-item span {
    font-size: 14px;
    font-weight: 500;
}

/* Settings */
.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-area-bottom));
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 8px;
}

.setting-item label {
    font-size: 16px;
}

.setting-item input[type="text"] {
    flex: 1;
    margin-left: 16px;
    padding: 8px 12px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: right;
}

.setting-item.toggle input[type="checkbox"] {
    width: 48px;
    height: 28px;
    appearance: none;
    background: var(--border);
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.setting-item.toggle input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.setting-item.toggle input[type="checkbox"]:checked {
    background: var(--primary);
}

.setting-item.toggle input[type="checkbox"]:checked::after {
    transform: translateX(20px);
}

.setting-item.info span {
    color: var(--text-secondary);
}

/* History */
.history-header {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.history-header input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
}

.history-header select {
    padding: 12px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

/* Uploads */
.uploads-header {
    margin-bottom: 16px;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.overlay p {
    color: white;
    margin-top: 16px;
    font-size: 16px;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 16px);
    left: 16px;
    right: 16px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    background: var(--text-primary);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    animation: slideUp 0.3s ease-out;
    pointer-events: auto;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .login-container {
        max-width: 400px;
    }

    .wizard-container {
        max-width: 600px;
        margin: 0 auto;
    }

    .stats-row {
        max-width: 600px;
    }

    .detail-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* iOS Safari adjustments */
@supports (-webkit-touch-callout: none) {
    .screen {
        min-height: -webkit-fill-available;
    }
}

/* ---------- Sign asset tag (step 4) ---------- */
.asset-tag-preview {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
}
.asset-tag-preview img {
    display: block;
    width: 100%;
    max-height: 240px;
    object-fit: contain;
    background: #000;
}
.asset-ocr-status {
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}
.asset-ocr-status.working { color: var(--primary); }
.asset-ocr-status.ok      { color: var(--success); }
.asset-ocr-status.warn    { color: var(--warning); }
#asset-number {
    text-transform: uppercase;
    letter-spacing: .04em;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}
