/* === 1. GLOBAL RESET & FONTS === */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%; /* Critical for full map */
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    overflow: hidden; /* Prevent scrolling on the main page */
}

/* === 2. FULL SCREEN MAP SHELL === */
#palmetum-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh; /* Forces it to take 100% of the screen height */
    width: 100vw;
}

#map {
    flex-grow: 1; /* Fills all available space */
    width: 100%;
    height: 100%;
    background: #e5e3df; /* Google Maps Loading Gray */
}


/* === SETUP OVERLAY (Landing Screen) === */
#setup-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;

    /* NEW BACKGROUND LOGIC */
    /* 1. The URL to your image */
    background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url('icons/background.png');
    
    /* 2. Scale to fill screen always */
    background-size: cover;
    
    /* 3. Center the image */
    background-position: center;
    background-repeat: no-repeat;
    
    /* 4. Optional: Blur the background slightly for focus */
    backdrop-filter: blur(5px);
}

.setup-card {
    background: white;
    width: 100%;
    max-width: 600px; /* Made Wider */
    padding: 50px;    /* More breathing room */
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    text-align: center;
}

/* Logo Styling (Restored) */
.setup-card img {
    width: 160px !important;
    height: auto;
    margin-bottom: 25px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 16px;
}

/* Section Spacing */
.setup-section { 
    margin-bottom: 25px; 
}

/* Divider "OR" (Restored) */
.divider { 
    margin: 25px 0; 
    border-top: 1px solid #eee; 
    position: relative; 
    color: #999; 
    font-weight: bold;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Dropdown Styling (Restored & Polished) */
.map-dropdown {
    width: 100%;
    padding: 15px 20px;       /* Larger touch area */
    font-size: 16px;          /* Easier to read */
    color: #333;
    background-color: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 50px;      /* Fully rounded edges (Pill shape) */
    appearance: none;         /* Removes default ugly browser arrow */
    cursor: pointer;
    transition: all 0.2s ease;
    
    /* Custom Arrow Icon */
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%231a5e1a%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 20px center;
    background-size: 12px;
}

.map-dropdown:hover {
    border-color: #1a5e1a; /* Highlight green on hover */
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(26, 94, 26, 0.1);
}

.map-dropdown:focus {
    outline: none;
    border-color: #1a5e1a;
    box-shadow: 0 0 0 4px rgba(26, 94, 26, 0.1);
}

/* File Drop Zone (Merged) */
.file-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 50px 30px; /* Large Drop Area */
    background: #f9f9f9;
    cursor: pointer;
    transition: all 0.2s;
}

.file-drop-zone:hover {
    border-color: #1a5e1a;
    background: #f0fdf0;
}

.file-drop-zone.drag-active {
    border-color: #1a5e1a;
    background-color: #e8f5e9;
    transform: scale(1.02);
}

.file-drop-zone input {
    display: none; /* Hide standard input */
}

/* === 4. SIDE PANEL (Refined) === */
#palm-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 340px;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-radius: 12px;
    transform: translateX(120%); /* Hidden by default */
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 100;
    max-height: 90vh;
    overflow-y: auto;
}

.panel-open { transform: translateX(0) !important; }
.panel-closed { transform: translateX(120%) !important; }

.panel-inner { padding: 25px; }

#panel-header h2 {
    margin: 0 0 5px 0;
    color: #1a5e1a;
    font-size: 24px;
}

.panel-common {
    font-size: 16px;
    color: #666;
    font-style: italic;
    margin-bottom: 20px;
}

/* === 5. EDIT CONTROLS (Buttons) === */
.panel-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.btn-delete {
    background-color: #fff;
    color: #d32f2f;
    border: 1px solid #d32f2f;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    flex-grow: 1;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-delete:hover {
    background-color: #ffebee;
}

/* === 6. TOP CONTROLS (Title Bar) === */
#top-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    background: white;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 50;
}

.btn-action {
    background: #1a5e1a;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
}

.btn-action:hover {
    background: #144a14;
}

/* === MOBILE OPTIMIZATIONS === */
@media (max-width: 768px) {
    
    /* 1. Turn Side Panel into Bottom Sheet */
    #palm-panel {
        top: auto;          /* Unset the top position */
        bottom: 0;          /* Stick to the bottom */
        left: 0; 
        right: 0;
        width: 100%;        /* Full width */
        max-height: 60vh;   /* Take up 60% of screen max */
        border-radius: 24px 24px 0 0; /* Round the top corners */
        
        /* Change Animation Direction (Up/Down instead of Left/Right) */
        transform: translateY(100%); 
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    }

    /* Override the slide animations for mobile */
    .panel-open { transform: translateY(0) !important; }
    .panel-closed { transform: translateY(100%) !important; }

    /* 2. Setup Screen Tweaks for Mobile */
    .setup-card {
        padding: 30px 20px; /* Less padding on small screens */
        width: 90%;         /* Don't touch the edges */
    }

    .file-drop-zone {
        padding: 40px 20px;
    }

    /* 3. Top Controls adjustment */
    #top-controls {
        left: 10px;
        right: 10px; /* Full width bar on top */
        top: 10px;
        justify-content: space-between;
    }
}

/* === MOBILE OPTIMIZATIONS (Refined) === */
@media (max-width: 768px) {
    
    /* 1. Fix the Dropdown (Force Containment & Rounding) */
    .map-dropdown {
        width: 100% !important;        /* Force full width of container */
        max-width: 100% !important;    /* Never let it exceed the screen */
        box-sizing: border-box;        /* Keep padding inside the width */
        
        display: block;
        margin: 0 auto 20px auto;      /* Center it */
        
        /* Aggressive Rounding for Mobile */
        border-radius: 50px !important; 
        -webkit-appearance: none;      /* Remove Apple default square style */
        -moz-appearance: none;         /* Remove Firefox default style */
        appearance: none;              /* Remove Standard default style */
        
        /* Text Handling */
        font-size: 16px;               /* Stop iOS Zoom */
        padding: 12px 20px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;       /* Add "..." if text is too long */
        
        /* Re-add the arrow since 'appearance: none' kills it */
        background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%231a5e1a%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
        background-repeat: no-repeat;
        background-position: right 15px center;
        background-size: 10px;
        background-color: #f8f9fa;
    }

    /* 2. Remove "Drag & Drop" Box */
    .file-drop-zone {
        display: none !important;
    }

    /* 3. Hide the Divider */
    .divider {
        display: none !important;
    }

    /* 4. Tweak the Setup Card */
    .setup-card {
        padding: 30px 20px;
        width: 85%;            /* Slightly narrower to ensure margin */
        max-width: 90vw;       /* Hard cap on width */
        margin-top: -10%;
        overflow: hidden;      /* Cut off anything sticking out */
    }
}