/* Global Variables & Theme Config */
:root {
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-header: #f1f5f9;
    --border-color: rgba(15, 23, 42, 0.08);
    --border-glow: rgba(59, 130, 246, 0.12);

    --text-main: #334155;
    --text-muted: #64748b;
    --text-bright: #0f172a;

    /* Status Colors */
    --color-available: #10b981;
    /* Emerald Green */
    --color-booked: #f59e0b;
    /* Amber Yellow */
    --color-sold: #3b82f6;
    /* Blue */
    --color-reserved: #f97316;
    /* Orange */
    --color-notfound: #ef4444;
    /* Red */
    --color-neutral: #94a3b8;
    /* Gray */

    /* Fonts */
    --font-primary: 'Inter', sans-serif;
    --font-display: 'Outfit', sans-serif;

    /* Leaflet customization */
    --map-bg: #ffffff;
}

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

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-primary);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    overflow-x: hidden;
}

/* Utility Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
    background: #2d3748;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a5568;
}

/* Application Wrapper */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Styles */
.dashboard-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.25rem;
    color: var(--color-sold);
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.logo-area h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--text-bright);
}

.logo-area .subtitle {
    font-size: 0.825rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: -0.15rem;
}

/* Statistics Widgets */
.stats-container {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.stat-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
}

/* Common Card Styles */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card-header {
    background-color: rgba(255, 255, 255, 0.01);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header.no-border {
    border-bottom: none;
}

.card-header h2,
.card-header h3,
.card h3 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-bright);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-icon {
    font-size: 1.25rem;
}

/* Dashboard Layout Grid */
.dashboard-main {
    max-width: 1600px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 2rem;
    flex-grow: 1;
}

/* Map Section */
.map-section {
    display: flex;
    flex-direction: column;
    height: 720px;
}

.map-wrapper {
    flex-grow: 1;
    position: relative;
    background-color: var(--map-bg);
}

#map {
    height: 100%;
    width: 100%;
    background-color: var(--map-bg);
}

/* Right Sidebar Panels */
.panel-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Legend Section */
.legend-card {
    padding: 1.25rem;
}

.legend-card h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.legend-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-bright);
    display: block;
}

.legend-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: block;
}

/* Color Badges & Helpers */
.color-badge {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-badge {
    font-size: 0.725rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Color Definitions */
.bg-green {
    background-color: var(--color-available);
    color: #fff;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.bg-yellow {
    background-color: var(--color-booked);
    color: #000;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.bg-blue {
    background-color: var(--color-sold);
    color: #fff;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.bg-orange {
    background-color: var(--color-reserved);
    color: #fff;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.3);
}

.bg-red {
    background-color: var(--color-notfound);
    color: #fff;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.bg-gray {
    background-color: var(--color-neutral);
    color: #fff;
}

.text-green {
    color: var(--color-available);
}

.text-yellow {
    color: var(--color-booked);
}

.text-blue {
    color: var(--color-sold);
}

.text-orange {
    color: var(--color-reserved);
}

.text-red {
    color: var(--color-notfound);
}

/* Details Panel & Form */
.details-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 380px;
    position: relative;
}

.details-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    border: 2px dashed rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}

.placeholder-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    opacity: 0.3;
}

.details-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

.form-row.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.form-row.header-row h4 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-bright);
}

.area-tag {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--color-sold);
    border: 1px solid rgba(59, 130, 246, 0.2);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.detail-item.full-width {
    grid-column: span 2;
}

.detail-item label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.form-input {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    color: var(--text-main);
    font-family: var(--font-primary);
    font-size: 0.85rem;
    outline: none;
    transition: all 0.25s ease;
}

.form-input:focus {
    border-color: var(--color-sold);
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px var(--border-glow);
}

.form-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-textarea {
    resize: none;
}

.separator {
    grid-column: span 2;
    font-size: 0.725rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 0.25rem;
    margin-top: 0.5rem;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.form-actions .timestamp {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Custom Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-primary);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.btn-primary {
    background-color: var(--color-sold);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background-color: #2563eb;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Plot Registry Table Panel */
.registry-card {
    padding: 1.25rem 1.5rem;
}

.registry-card h3 {
    margin-bottom: 1rem;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.registry-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.825rem;
}

.registry-table th {
    background-color: rgba(255, 255, 255, 0.015);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.65rem 1rem;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

.registry-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.registry-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.registry-table tbody tr:last-child td {
    border-bottom: none;
}

.registry-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.registry-table tbody tr.selected {
    background-color: rgba(59, 130, 246, 0.06);
}

.registry-table tbody tr.selected td {
    color: var(--text-bright);
}

.loading-cell {
    text-align: center;
    padding: 2rem !important;
    color: var(--text-muted);
}

/* Footer Section */
.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-card);
    margin-top: auto;
}

/* Leaflet Dark Customizations */
.leaflet-container {
    color: var(--text-bright);
    font-family: var(--font-primary);
}

.leaflet-interactive:focus {
    outline: none;
}

.leaflet-bar {
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-bar a {
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border-bottom: 1px solid var(--border-color) !important;
    transition: all 0.2s ease;
}

.leaflet-bar a:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-bright) !important;
}

.leaflet-popup-content-wrapper {
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5) !important;
    border-radius: 8px !important;
}

.leaflet-popup-tip {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-tooltip {
    background-color: rgba(17, 24, 39, 0.9) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    border-radius: 4px !important;
    font-weight: 600 !important;
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
}

/* Animations */
.animate-spin-slow {
    animation: spin 8s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}

/* Custom Tooltip Label Marker style */
.plot-label-marker {
    background: transparent;
    border: none;
    box-shadow: none;
}

.plot-label-inner {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    color: #1e293b;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(15, 23, 42, 0.12);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
    .dashboard-main {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .map-section {
        height: 550px;
    }
}

@media (max-width: 768px) {
    .header-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .stats-container {
        width: 100%;
        justify-content: space-between;
    }

    .stat-card {
        flex-grow: 1;
    }

    .details-grid {
        grid-template-columns: 1fr;
    }

    .detail-item.full-width {
        grid-column: span 1;
    }

    .separator {
        grid-column: span 1;
    }
}