/* styles.css - Complete updated version */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --ai-color: #9b59b6;
    --light-bg: #ecf0f1;
    --dark-bg: #34495e;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--light-bg);
    color: var(--text-color);
    overflow: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    gap: 2rem;
}

.header-content h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 600;
}

.header-content h1 i {
    color: var(--secondary-color);
    margin-right: 0.5rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Search Container */
.header-search {
    flex: 1;
    max-width: 400px;
    min-width: 250px;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 2.5rem;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.search-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    color: #7f8c8d;
    z-index: 10;
}

.search-clear {
    position: absolute;
    right: 0.5rem;
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    border-radius: 50%;
    cursor: pointer;
    color: #7f8c8d;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.search-clear:hover {
    background: var(--light-bg);
    color: var(--text-color);
}

.search-clear.visible {
    display: flex;
}

/* Search Autocomplete Styling */
.pac-container {
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    border: none;
    margin-top: 5px;
}

.pac-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f8f9fa;
    cursor: pointer;
}

.pac-item:hover {
    background: var(--light-bg);
}

.pac-item-selected {
    background: var(--secondary-color);
    color: white;
}

.pac-matched {
    font-weight: 600;
}

.pac-icon {
    margin-right: 0.5rem;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
    background: #f8f9fa;
}

#map {
    width: 100%;
    height: 100%;
}

/* Map Controls */
.map-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.control-group {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.control-btn {
    width: 50px;
    height: 50px;
    border: none;
    background: white;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid var(--border-color);
}

.control-btn:last-child {
    border-bottom: none;
}

.control-btn:hover {
    background: var(--light-bg);
    color: var(--secondary-color);
}

.control-btn.active {
    background: var(--secondary-color);
    color: white;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.loading-overlay.hidden {
    display: none;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    max-width: 350px;
    box-shadow: var(--shadow-hover);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--light-bg);
    border-top: 4px solid var(--ai-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: white;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.05);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.panel {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.panel h3 {
    background: var(--light-bg);
    padding: 1rem;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
}

.panel h3 i {
    margin-right: 0.5rem;
    color: var(--secondary-color);
}

/* Form Styles */
.form-group {
    padding: 1rem;
    border-bottom: 1px solid #f8f9fa;
}

.form-group:last-child {
    border-bottom: none;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-input, .form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Color Picker */
.color-picker-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.color-input {
    width: 60px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

.color-presets {
    display: flex;
    gap: 0.5rem;
}

.color-preset {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.color-preset:hover {
    transform: scale(1.1);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.btn-primary {
    background: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #219a52;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-ai {
    background: var(--ai-color);
    color: white;
}

.btn-ai:hover {
    background: #8e44ad;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
}

.button-group .btn {
    flex: 1;
}

/* Paddock List */
.paddock-list {
    max-height: 300px;
    overflow-y: auto;
}

.paddock-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f8f9fa;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.paddock-item:hover {
    background: var(--light-bg);
}

.paddock-item.selected {
    background: rgba(52, 152, 219, 0.1);
    border-left: 3px solid var(--secondary-color);
}

.paddock-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 0.75rem;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.paddock-info {
    flex: 1;
}

.paddock-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.paddock-area {
    font-size: 12px;
    color: #7f8c8d;
}

.paddock-actions {
    display: flex;
    gap: 0.25rem;
}

.paddock-action {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    color: #7f8c8d;
    transition: all 0.2s ease;
}

.paddock-action:hover {
    background: var(--light-bg);
    color: var(--text-color);
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: #7f8c8d;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #bdc3c7;
}

/* AI Results Panel */
.ai-summary {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.ai-summary p {
    margin: 0 0 0.5rem 0;
}

.ai-summary p:last-child {
    margin-bottom: 0;
}

.ai-paddocks {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.ai-paddock-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: white;
}

.ai-paddock-item:last-child {
    margin-bottom: 0;
}

.ai-paddock-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 0.75rem;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.ai-paddock-info {
    flex: 1;
}

.ai-paddock-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-color);
}

.ai-paddock-area {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.ai-paddock-coords {
    font-size: 11px;
    color: #8e9297;
    margin-bottom: 0.25rem;
}

.ai-confidence {
    font-size: 11px;
    color: #28a745;
    font-weight: 500;
}

.ai-no-results {
    padding: 1rem;
    text-align: center;
    color: #6c757d;
}

.ai-no-results p {
    margin: 0 0 0.5rem 0;
}

.ai-notes {
    padding: 0.75rem;
    background: #e8f4f8;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 12px;
    color: #495057;
    line-height: 1.4;
}

/* Make sure AI results panel is visible */
#aiResultsPanel {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

#aiResultsPanel h3 {
    background: linear-gradient(135deg, var(--ai-color), #8e44ad);
    color: white;
    padding: 1rem;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

#aiResultsPanel h3 i {
    margin-right: 0.5rem;
}

#aiResults {
    padding: 0;
}

/* Button group for AI results */
#aiResultsPanel .button-group {
    border-top: 1px solid var(--border-color);
    background: #f8f9fa;
}

#aiResultsPanel .button-group .btn {
    font-size: 13px;
    padding: 0.6rem 1rem;
}

/* Enhanced visibility for debugging */
#aiResultsPanel[style*="display: block"] {
    display: block !important;
    animation: slideDown 0.3s ease;
}

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    border-left: 4px solid var(--success-color);
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

.toast.info {
    border-left-color: var(--secondary-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: 50vh;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
    
    .main-content {
        flex-direction: column;
    }
    
    .map-container {
        height: 50vh;
    }
    
    .header-content {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-search {
        max-width: 100%;
        order: 2;
    }
    
    .header-actions {
        width: 100%;
        justify-content: center;
        order: 3;
    }
}