/* 
  Visit Route - iOS 26 Liquid Glass Design System
  Color Palette: Teals, Purples, Deep Blues, Whites 
*/

:root {
    /* Safe Area Insets for iOS */
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);

    /* Light Theme */
    --bg-color: #f2f2f7;
    --text-primary: #1c1c1e;
    --text-secondary: #8e8e93;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: rgba(0, 0, 0, 0.05);

    /* Gradients / Brand Colors */
    --accent-start: #007aff;
    --accent-end: #5856d6;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;
    
    /* Liquid Glass Effect variables */
    --blur-strong: blur(24px) saturate(180%);
    --blur-medium: blur(16px) saturate(180%);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000000;
        --text-primary: #f2f2f7;
        --text-secondary: #aeaeb2;
        --glass-bg: rgba(28, 28, 30, 0.65);
        --glass-border: rgba(255, 255, 255, 0.1);
        --glass-shadow: rgba(0, 0, 0, 0.3);
    }
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Noto Sans KR", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Typography Utilities */
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-gradient {
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Mobile safari support */
    overflow: hidden;
}

.app-header {
    padding: calc(var(--safe-top) + 12px) 16px 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--glass-border);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
}
.icon-btn:active { transform: scale(0.9); }

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: calc(var(--safe-bottom) + 80px); /* Leave room for bottom nav */
}

/* Tabs */
.tab-pane {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.tab-pane.active {
    display: block;
    opacity: 1;
}
.fade-in { animation: fadeIn 0.3s ease forwards; }

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

/* Glass UI Elements */
.glass-effect, .glass-card, .glass-nav {
    background: var(--glass-bg);
    backdrop-filter: var(--blur-strong);
    -webkit-backdrop-filter: var(--blur-strong);
    border: 1px solid var(--glass-border);
}

.glass-card {
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px var(--glass-shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h2 { font-size: 1.1rem; font-weight: 600; }
.card-body { padding: 16px; }

/* Forms & Inputs */
.input-group, .form-group {
    margin-bottom: 12px;
}
.input-group label, .form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
input.input-control, textarea.input-control, .input-group input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.2);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}
@media (prefers-color-scheme: dark) {
    input.input-control, textarea.input-control, .input-group input {
        background: rgba(0,0,0,0.2);
    }
}
input.input-control:focus, textarea.input-control:focus, .input-group input:focus {
    border-color: var(--accent-start);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

/* Toggle Switches */
.toggle-switch-container {
    display: flex;
    background: rgba(120, 120, 128, 0.16);
    border-radius: var(--radius-sm);
    padding: 2px;
}
.toggle-label {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.toggle-label.active {
    background: #ffffff;
    color: #000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
@media (prefers-color-scheme: dark) {
    .toggle-label.active {
        background: #3a3a3c;
        color: #fff;
    }
}

/* Buttons */
.btn {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; border-radius: var(--radius-sm); }
.btn-full { width: 100%; display: block; }
.btn-primary { background: var(--accent-start); color: #fff; }
.btn-gradient {
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
}
.btn-secondary {
    background: rgba(120, 120, 128, 0.16);
    color: var(--text-primary);
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-primary);
}
.btn-danger { background: var(--danger); color: white; }
.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}
.btn-action {
    background: var(--text-primary);
    color: var(--bg-color);
    border: none;
}
.action-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* Utilities */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 32px; }
.p-0 { padding: 0 !important; }
.p-4 { padding: 24px; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }

/* Lists & Cards */
.sortable-list {
    list-style: none;
}
.list-item, .visit-card, .manage-card {
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
    background: transparent;
    transition: background 0.2s;
}
.list-item:last-child { border-bottom: none; }
.list-item.dragging {
    background: var(--glass-bg);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    border-radius: var(--radius-md);
}
.empty-state {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Recipient Info Layout */
.recipient-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.order-badge {
    background: var(--text-primary);
    color: var(--bg-color);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.info-body { flex: 1; overflow: hidden; }
.info-name { font-weight: 600; font-size: 1.05rem; margin-bottom: 2px; }
.info-addr, .info-note { font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drag-handle { color: var(--text-secondary); cursor: grab; padding: 4px; }

/* Map */
.map-container {
    height: 300px;
    width: 100%;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    z-index: 1;
}

/* Progress Bar */
.progress-container {
    padding: 16px;
}
.progress-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 8px;
}
.progress-bar-bg {
    height: 8px;
    background: rgba(120, 120, 128, 0.2);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-start), var(--success));
    width: 0%;
    transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Visit Cards - TAB 2 */
.visit-card.active {
    border: 2px solid var(--accent-end);
    border-radius: var(--radius-md);
    margin: 8px 0;
    background: rgba(88, 86, 214, 0.05);
}
.visit-card.completed {
    opacity: 0.6;
}
.visit-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.btn-nav {
    background: #FFD500;
    color: #000;
    border: none;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding-bottom: var(--safe-bottom);
    height: calc(65px + var(--safe-bottom));
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--glass-border);
    z-index: 100;
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    gap: 4px;
    transition: color 0.2s;
    cursor: pointer;
    height: 100%;
}
.nav-item i { font-size: 1.25rem; }
.nav-item span { font-size: 0.75rem; font-weight: 500; }
.nav-item.active { color: var(--accent-start); }

/* Modals & Overlays */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: none;
    justify-content: center;
    align-items: center;
}
.modal-overlay.active { display: flex; }

.modal-content {
    width: 90%;
    max-width: 400px;
    position: relative;
    z-index: 201;
}

/* Blobs for Login Background */
.blob {
    position: absolute;
    filter: blur(60px);
    z-index: 200;
    opacity: 0.6;
    border-radius: 50%;
    animation: float 10s infinite ease-in-out;
}
.shape-1 {
    width: 250px; height: 250px;
    background: #007aff;
    top: -50px; left: -50px;
}
.shape-2 {
    width: 200px; height: 200px;
    background: #5856d6;
    bottom: -50px; right: -50px;
    animation-delay: -5s;
}
@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.1); }
}

/* Bottom Sheet */
.bottom-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background: var(--bg-color);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    z-index: 300;
    transition: bottom 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.bottom-sheet.active { bottom: 0; }
.sheet-handle {
    width: 40px;
    height: 5px;
    background: rgba(120, 120, 128, 0.5);
    border-radius: 3px;
    margin: 8px auto;
}
.sheet-header {
    padding: 8px 16px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}
.sheet-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}
.btn-close {
    background: rgba(120, 120, 128, 0.16);
    border: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
}

/* Chips */
.chip-group { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.chip.active {
    background: var(--accent-start);
    color: #fff;
    border-color: var(--accent-start);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.stat-card {
    padding: 12px;
    text-align: center;
}
.stat-title { font-size: 0.8rem; font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.5rem; font-weight: 700; }

/* Filter Scroll */
.scroll-x {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 8px;
}
.scroll-x::-webkit-scrollbar { display: none; }
.filter-btn {
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(120, 120, 128, 0.16);
    border: none;
    color: var(--text-primary);
    white-space: nowrap;
    cursor: pointer;
}
.filter-btn.active { background: var(--text-primary); color: var(--bg-color); }

/* Toasts */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    background: rgba(28, 28, 30, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}

/* Image Upload Preview */
#photoPreviewArea img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius-md);
}
