:root { 
    --primary-blue: #007AFF; 
    --sidebar-width: 350px; 
    --detail-width: 400px; 
}
body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; font-family: sans-serif; }

#top-interface {
    position: absolute; top: 0; left: 0; right: 0; z-index: 100;
    padding: 15px; display: flex; flex-direction: column; align-items: center; gap: 10px;
    pointer-events: none;
}
.info-bar, .category-container { pointer-events: auto; }
.info-bar { background: rgba(0,0,0,0.7); color: white; padding: 8px 20px; border-radius: 20px; font-size: 13px; }
.category-container { display: flex; gap: 10px; }
.cat-btn {
    background: white; border: none; padding: 10px 18px; border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2); cursor: pointer; font-weight: bold;
}

#map { position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 1; }

#side-panel {
    position: absolute; top: 100px; left: 20px; bottom: 20px; z-index: 50;
    display: flex; pointer-events: none;
}
.panel {
    background: white; height: 100%; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    pointer-events: auto; overflow-y: auto; display: none;
}
#list-window { width: var(--sidebar-width); margin-right: 10px; }
#detail-window { width: var(--detail-width); }

.list-item { padding: 15px; border-bottom: 1px solid #eee; cursor: pointer; }
.list-item:hover { background: #f8f9fa; }
.detail-header { padding: 20px; border-bottom: 1px solid #eee; }

/* Loading, Empty, and Error Messages */
.loading, .empty-message, .error-message {
    padding: 20px;
    text-align: center;
    color: #666;
}

.error-message {
    color: #d32f2f;
}

.error-message button {
    margin-top: 10px;
    padding: 8px 16px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* Add Item Button */
.btn-add-item {
    width: calc(100% - 30px);
    margin: 15px;
    padding: 12px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-add-item:hover {
    background: #0056d2;
}

/* Detail Actions (Edit/Delete Buttons) */
.detail-body {
    padding: 20px;
}

.detail-actions {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.btn-edit, .btn-delete {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit {
    background: var(--primary-blue);
    color: white;
}

.btn-edit:hover {
    background: #0056d2;
}

.btn-delete {
    background: #f44336;
    color: white;
}

.btn-delete:hover {
    background: #d32f2f;
}

.btn-close {
    background: #f0f0f0;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    float: right;
}

.btn-close:hover {
    background: #e0e0e0;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

/* Form Styles */
.item-form {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 14px;
    color: #333;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.btn-cancel,
.btn-submit {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel {
    background: #f0f0f0;
    color: #333;
}

.btn-cancel:hover {
    background: #e0e0e0;
}

.btn-submit {
    background: var(--primary-blue);
    color: white;
}

.btn-submit:hover {
    background: #0056d2;
}

/* Google Maps InfoWindow Customization */
.gm-style .gm-style-iw-c {
    padding: 0 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
    padding: 0 !important;
}

.gm-style .gm-style-iw-t::after {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
}

/* Hide the close button on hover info window */
.gm-style button[title="Close"] {
    display: none !important;
}

/* Responsive Design - Mobile Bottom Sheet (Google Maps Style) */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: none;
    }

    /* Mobile: Bottom Sheet Layout */
    #side-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        height: 65vh;
        max-height: 85vh;
        flex-direction: column;
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        z-index: 100;
        /* Default: Peek mode - only show handle and title */
        transform: translateY(calc(100% - 60px));
    }

    /* Expanded state (when user drags up or clicks list) */
    #side-panel.expanded {
        transform: translateY(0);
    }

    /* Collapsed state (middle) */
    #side-panel.collapsed {
        transform: translateY(calc(100% - 120px));
    }

    /* Peek mode - show handle and title hint */
    #side-panel.peek {
        transform: translateY(calc(100% - 60px));
    }

    /* In peek mode, hide content except header */
    #side-panel.peek #item-list {
        opacity: 0;
        pointer-events: none;
    }

    /* Smooth transition for content visibility */
    #item-list {
        opacity: 1;
        transition: opacity 0.2s;
    }

    /* Expanded state shows everything */
    #side-panel.expanded #item-list {
        opacity: 1;
        pointer-events: auto;
    }

    /* Bottom sheet panels */
    #list-window,
    #detail-window {
        width: 100%;
        margin: 0;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    /* Drag handle for bottom sheet - more prominent */
    .panel::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 50px;
        height: 5px;
        background: #d0d0d0;
        border-radius: 3px;
        cursor: grab;
        z-index: 10;
    }

    .panel:active::before {
        cursor: grabbing;
        background: #999;
    }

    /* List items - more compact */
    .list-item {
        padding: 12px 15px;
    }

    .list-item h3 {
        font-size: 14px;
        margin: 0 0 4px 0;
    }

    .list-item p {
        font-size: 12px;
        margin: 0;
        color: #666;
    }

    /* List header - compact and smaller */
    .list-header {
        padding: 18px 15px 12px 15px;
    }

    .list-header h2 {
        font-size: 16px;
        margin: 0;
        font-weight: 600;
    }

    /* Mobile: Category buttons - more compact */
    .category-container {
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }

    .cat-btn {
        padding: 6px 12px;
        font-size: 12px;
        font-weight: 600;
        border-radius: 15px;
    }

    /* Mobile: Info bar - more compact */
    .info-bar {
        font-size: 10px;
        padding: 5px 12px;
        border-radius: 15px;
    }

    /* Mobile: Top interface - very compact */
    #top-interface {
        padding: 8px;
        gap: 6px;
    }

    /* Mobile: Auth UI adjustments */
    .auth-container {
        top: 10px;
        right: 10px;
    }

    .auth-btn {
        padding: 8px 16px;
        font-size: 0.9em;
    }

    .user-name {
        display: none;
    }

    #user-menu {
        padding: 6px 10px;
    }

    .login-prompt {
        padding: 15px;
        font-size: 0.9em;
    }
}

/* Google Places Autocomplete Styling */
.pac-container {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #ddd;
    margin-top: 5px;
    font-family: sans-serif;
    z-index: 10000 !important; /* Ensure it appears above modal */
}

.pac-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    line-height: 1.5;
}

.pac-item:hover {
    background-color: #f8f9fa;
}

.pac-item:last-child {
    border-bottom: none;
}

.pac-item-query {
    font-size: 14px;
    color: #333;
}

.pac-matched {
    font-weight: bold;
    color: var(--primary-blue);
}

.pac-icon {
    margin-top: 4px;
}

/* Address input hint */
.form-group input[id*="address"] {
    padding-right: 40px;
}

.form-group input[id*="address"]::placeholder {
    color: #999;
    font-style: italic;
}

/* ============================================================================
   Authentication UI Styles
   ============================================================================ */

/* Auth Container */
.auth-container {
    position: absolute;
    top: 15px;
    right: 20px;
    z-index: 200;
    pointer-events: auto;
}

/* Login Button */
.auth-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* User Menu */
#user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 8px 15px;
    border-radius: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    position: relative;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #667eea;
}

.user-name {
    font-weight: 600;
    color: #333;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* User Dropdown */
.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    overflow: hidden;
}

#user-menu:hover .user-dropdown {
    display: block;
}

.user-dropdown a {
    display: block;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.user-dropdown a:last-child {
    border-bottom: none;
}

.user-dropdown a:hover {
    background-color: #f8f9fa;
}

/* Login Prompt in List */
.login-prompt {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    margin: 0 0 15px 0;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
}

.btn-login-prompt {
    background: white;
    color: #667eea;
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s;
}

.btn-login-prompt:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Ownership Notice in Detail View */
.ownership-notice {
    background-color: #f5f5f5;
    border: 2px dashed #ddd;
    padding: 15px 20px;
    margin: 20px;
    border-radius: 8px;
    text-align: center;
    color: #666;
    font-size: 0.95em;
}

.ownership-notice a {
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
}

.ownership-notice a:hover {
    text-decoration: underline;
}

/* ============================================================================
   Toast Notification
   ============================================================================ */

#toast-container {
    position: fixed;
    bottom: 30px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    pointer-events: auto;
    max-width: 320px;
    word-break: break-word;
    line-height: 1.4;
}

.toast.success { background: #4CAF50; }
.toast.error   { background: #f44336; }
.toast.info    { background: #2196F3; }
.toast.warning { background: #FF9800; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(16px); }
}

@media (max-width: 768px) {
    #toast-container {
        bottom: 100px;
        right: 15px;
        left: 15px;
    }
    .toast { max-width: none; }
}

/* Responsive adjustments for auth UI */
@media (max-width: 768px) {
    .auth-container {
        top: 10px;
        right: 10px;
    }

    .auth-btn {
        padding: 8px 16px;
        font-size: 0.9em;
    }

    .user-name {
        display: none;
    }

    #user-menu {
        padding: 6px 10px;
    }

    .login-prompt {
        padding: 15px;
        font-size: 0.9em;
    }
}