/* =============================================
   FO POINT MANAGEMENT SYSTEM - MAIN STYLES
   ============================================= */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 72px;
    --header-height: 56px;
    --border-radius: 4px;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --transition: all 0.3s ease;
}

/* ======================
   GLOBAL STYLES
   ====================== */

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    color: #495057;
}

.main-container {
    display: flex;
    flex: 1;
}

/* ======================
   HEADER & NAVIGATION
   ====================== */

.navbar {
    height: var(--header-height);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background-color: #212529;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.1rem;
    color: white !important;
}

.sidebar-toggle {
    position: static;
    z-index: 1001;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
    flex: 0 0 auto;
    box-shadow: var(--box-shadow);
    cursor: pointer;
}

/* ======================
   SIDEBAR STYLES
   ====================== */

.sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    border-right: 1px solid #ddd;
    background: #f8f9fa;
    padding: 1rem;
    position: fixed;
    top: var(--header-height);
    left: 0;
    transform: translateX(-100%);
    transition: width 0.3s ease, transform 0.3s ease, padding 0.3s ease;
    z-index: 1000;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.sidebar.active {
    transform: translateX(0);
}

.sidebar .nav-link {
    margin-bottom: 5px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    padding: 0.5rem 1rem;
    font-weight: 500;
    color: #495057;
}

.sidebar .nav-link:hover {
    background-color: rgba(13, 110, 253, 0.1);
    color: var(--primary-color);
}

.sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
    margin-right: 8px;
}

/* ======================
   MAIN CONTENT AREA
   ====================== */

.content {
    flex: 1;
    margin-left: 0;
    padding: 1.5rem;
    transition: var(--transition);
}

.content .card {
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.125);
}

.content .card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

/* ======================
   MAP STYLES
   ====================== */

#map {
    width: 100%;
    height: calc(100vh - var(--header-height));
    min-height: 400px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
}

#coordinate-map, #layer-map {
    min-height: 400px;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: border-color 0.3s ease;
}

#coordinate-map:focus-within, #layer-map:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.maplibregl-ctrl {
    border-radius: var(--border-radius) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #ddd !important;
}

.maplibregl-ctrl-group {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #ddd !important;
    border-radius: var(--border-radius) !important;
}

/* ======================
   FORM STYLES
   ====================== */

.form-control {
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    padding: 0.5rem 0.75rem;
    transition: var(--transition);
    font-size: 1rem;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-control:required {
    background-color: #f8f9fa;
}

.form-control:focus:required {
    background-color: #fff;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #212529;
}

.form-text {
    font-size: 0.85rem;
    color: #6c757d;
}

.input-group-text {
    background-color: #e9ecef;
    border-right: none;
    border-color: #ced4da;
}

/* ======================
   TABLE & DASHBOARD STYLES
   ====================== */

.table-responsive {
    margin-bottom: 1rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

.table th {
    font-weight: 600;
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    color: #212529;
}

.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

.badge.bg-success {
    background-color: #d1e7dd;
    color: #0f5132;
}

.badge.bg-info {
    background-color: #cff4fc;
    color: #055160;
}

.badge.bg-warning {
    background-color: #fff3cd;
    color: #664d03;
}

.badge.bg-primary {
    background-color: #cfe2ff;
    color: #084298;
}

/* ======================
   BUTTON STYLES
   ====================== */

.btn {
    border-radius: var(--border-radius);
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

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

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

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

.btn-danger:hover {
    background-color: #bb2d3b;
    border-color: #b02a37;
}

.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
    color: #212529;
}

.btn-warning:hover {
    background-color: #ffca2c;
    border-color: #ffc720;
    color: #212529;
}

.btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
    color: #212529;
}

.btn-info:hover {
    background-color: #31d2f2;
    border-color: #25cff2;
    color: #212529;
}

.delete-btn:hover {
    transform: scale(1.1);
    transition: transform 0.2s;
}

.btn-outline-secondary:hover {
    background-color: #6c757d;
    color: white;
}

/* ======================
   MODAL STYLES
   ====================== */

.modal-header {
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 1rem;
}

.modal-content {
    border-radius: var(--border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border: none;
}

.modal-backdrop.show {
    opacity: 0.7;
}

/* ======================
   ALERT & NOTIFICATION STYLES
   ====================== */

.alert {
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    padding: 0.75rem 1.25rem;
    position: relative;
    border: 1px solid transparent;
}

.alert-dismissible .btn-close {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.75rem 1.25rem;
}

.alert-success {
    color: #0f5132;
    background-color: #d1e7dd;
    border-color: #badbcc;
}

.alert-danger {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
}

.alert-info {
    color: #055160;
    background-color: #cff4fc;
    border-color: #b6effb;
}

.alert-warning {
    color: #664d03;
    background-color: #fff3cd;
    border-color: #ffecb5;
}

/* ======================
   LAYER MANAGEMENT STYLES
   ====================== */

.badge.bg-light {
    border: 1px solid #ddd;
    color: #212529;
}

pre {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 0.75rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

/* ======================
   MAP POPUP STYLES
   ====================== */

.maplibregl-popup-content {
    padding: 10px !important;
    max-width: 300px !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.maplibregl-popup-content h5 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    font-size: 1rem;
    font-weight: 600;
}

.maplibregl-popup-content p {
    margin-bottom: 3px;
    line-height: 1.4;
    font-size: 0.875rem;
}

.maplibregl-popup-content strong {
    color: #495057;
    font-weight: 500;
}

.popup-content .btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    margin-left: 0.2rem;
}

/* ======================
   ANIMATION EFFECTS
   ====================== */

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.marker-pulse {
    animation: pulse 2s infinite;
}

.spinner-border {
    width: 2rem;
    height: 2rem;
    border-width: 0.25em;
}

/* ======================
   RESPONSIVE STYLES
   ====================== */

@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0);
    }
    .content {
        margin-left: var(--sidebar-width);
    }
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width);
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    body.sidebar-collapsed .content {
        margin-left: var(--sidebar-collapsed-width);
    }
    body.sidebar-collapsed .sidebar .nav-link {
        font-size: 0;
        text-align: center;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    body.sidebar-collapsed .sidebar .nav-link i {
        font-size: 1.15rem;
        margin-right: 0 !important;
    }
    body.sidebar-collapsed .sidebar .ms-4,
    body.sidebar-collapsed .sidebar small {
        display: none;
    }
}

@media (max-width: 991px) {
    .row > .col-lg-6 {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 768px) {
    .d-flex {
        flex-direction: column;
    }
    .d-md-flex {
        flex-direction: row;
    }
    .sidebar-toggle {
        left: auto;
        right: 10px;
    }
    .card-header .btn-group {
        margin-top: 0.5rem;
        width: 100%;
    }
    .card-header .btn-group .btn {
        flex: 1;
    }
    .alert-dismissible .btn-close {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }
}

@media (max-width: 576px) {
    #map, #coordinate-map, #layer-map {
        min-height: 300px;
    }
    .content {
        padding: 1rem;
    }
    .table-responsive {
        font-size: 0.85rem;
    }
    .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
    .form-label {
        font-size: 0.9rem;
    }
    .navbar-brand {
        font-size: 1rem;
    }
    .sidebar .nav-link {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
}

/* ======================
   UTILITY CLASSES
   ====================== */

.text-primary {
    color: var(--primary-color) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.text-warning {
    color: var(--warning-color) !important;
}

.bg-primary-light {
    background-color: rgba(13, 110, 253, 0.1) !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.p-3 {
    padding: 1rem !important;
}

.py-5 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
}

.z-index-1000 {
    z-index: 1000 !important;
}

.position-absolute {
    position: absolute !important;
}

.bottom-0 {
    bottom: 0 !important;
}

.start-50 {
    left: 50% !important;
}

.translate-middle-x {
    transform: translateX(-50%) !important;
}

/* ======================
   EMPTY STATE STYLES
   ====================== */

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

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

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* ======================
   LOADING STATE STYLES
   ====================== */

.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid rgba(13, 110, 253, 0.2);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ======================
   CUSTOM CARD STYLES
   ====================== */

.card-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    padding: 0.75rem 1.25rem;
}

.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-info,
.card-header.bg-danger {
    color: white;
    font-weight: 600;
    border-bottom: none;
}

.card-header.bg-primary {
    background-color: var(--primary-color) !important;
}

.card-header.bg-success {
    background-color: var(--success-color) !important;
}

.card-header.bg-info {
    background-color: var(--info-color) !important;
}

.card-header.bg-danger {
    background-color: var(--danger-color) !important;
}

.card.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1) !important;
}

/* ======================
   CUSTOM FORM STYLES
   ====================== */

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-select {
    border-radius: var(--border-radius);
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    border: 1px solid #ced4da;
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* ======================
   CUSTOM TABLE STYLES
   ====================== */

.table th:first-child,
.table td:first-child {
    padding-left: 1.5rem;
}

.table th:last-child,
.table td:last-child {
    padding-right: 1.5rem;
}

/* ======================
   COORDINATE PICKER STYLES
   ====================== */

.coordinate-input-group {
    display: flex;
    gap: 0.5rem;
}

.coordinate-input-group .form-control {
    flex: 1;
}

/* ======================
   UPLOAD PROGRESS STYLES
   ====================== */

.upload-progress {
    height: 8px;
    margin-top: 8px;
    border-radius: 4px;
    overflow: hidden;
    background-color: #e9ecef;
}

.upload-progress-bar {
    height: 100%;
    background-color: #0d6efd;
    transition: width 0.3s ease;
}

/* ======================
   FILE SIZE STYLES
   ====================== */

.file-size-warning {
    color: #dc3545;
    font-weight: 500;
    font-size: 0.85rem;
}

.file-size-normal {
    color: #198754;
    font-size: 0.85rem;
}

/* ======================
   FINAL MEDIA QUERIES
   ====================== */

@media print {
    .sidebar, .navbar, .btn, .card-header, .modal, .maplibregl-control-container {
        display: none !important;
    }
    .content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .table {
        width: 100% !important;
    }
    .card {
        box-shadow: none !important;
        border: none !important;
    }
    #map {
        display: none !important;
    }
}