* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
#sidebar {
    width: 320px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    z-index: 10;
}

#sidebar h2 {
    padding: 20px;
    background: #1a252f;
    margin: 0;
    font-size: 1.3rem;
}

#sidebar .info {
    padding: 15px 20px;
    background: #34495e;
    border-bottom: 1px solid #3d566e;
}

#sidebar .info p {
    margin: 5px 0;
}

#sidebar .hint {
    font-size: 12px;
    color: #bdc3c7;
    margin-top: 8px;
}

#polygonInfo {
    padding: 20px;
    flex: 1;
}

#polygonInfo h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    border-left: 3px solid #3498db;
    padding-left: 10px;
}

.info-content {
    background: #34495e;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.info-content .placeholder {
    color: #95a5a6;
    text-align: center;
}

.info-content p {
    margin: 8px 0;
}

.info-content label {
    display: block;
    margin-top: 10px;
    font-size: 12px;
    color: #bdc3c7;
}

.info-content input,
.info-content textarea {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    border: none;
    border-radius: 4px;
    background: #2c3e50;
    color: white;
    font-family: inherit;
}

.info-content textarea {
    resize: vertical;
    min-height: 60px;
}

.info-content button {
    margin-top: 10px;
    margin-right: 8px;
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-save {
    background: #27ae60;
    color: white;
}

.btn-save:hover {
    background: #2ecc71;
}

.btn-delete {
    background: #c0392b;
    color: white;
}

.btn-delete:hover {
    background: #e74c3c;
}

.btn-cancel {
    background: #7f8c8d;
    color: white;
}

.btn-cancel:hover {
    background: #95a5a6;
}

.btn-secondary {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px;
    margin: 0 20px 20px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #2980b9;
}

.footer {
    padding: 15px 20px;
    background: #1a252f;
    font-size: 11px;
    text-align: center;
    color: #7f8c8d;
}

/* Peta */
#map {
    flex: 1;
    height: 100vh;
}

/* Responsive */
@media (max-width: 700px) {
    #sidebar {
        width: 280px;
        position: absolute;
        left: -280px;
        transition: left 0.3s;
        height: 100vh;
        z-index: 1000;
    }
    
    #sidebar.open {
        left: 0;
    }
}

/* ============================================ */
/* TOOL SPLIT POLYGON */
/* ============================================ */

.tool-section {
    padding: 15px 20px;
    background: #34495e;
    border-bottom: 1px solid #3d566e;
}

.tool-section h3 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: #f39c12;
}

.selected-polygon-info {
    background: #2c3e50;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 12px;
}

.selected-polygon-info .selected-name {
    color: #f39c12;
    font-weight: bold;
}

.btn-split-mode {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.btn-split-mode:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}

.btn-split-mode.active {
    background: linear-gradient(135deg, #e67e22, #d35400);
    box-shadow: 0 0 0 2px rgba(243, 156, 18, 0.5);
}

.btn-split-mode:disabled {
    background: #7f8c8d;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-split-cancel {
    width: 100%;
    padding: 10px;
    background: #7f8c8d;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-split-cancel:hover {
    background: #95a5a6;
}

.hint-split {
    font-size: 11px;
    color: #bdc3c7;
    margin-top: 8px;
    text-align: center;
    line-height: 1.5;
}

/* Highlight polygon yang dipilih untuk split */
.polygon-selected-split {
    stroke: #f39c12 !important;
    stroke-width: 4 !important;
    fill-opacity: 0.6 !important;
}

/* ============================================ */
/* LABEL POLYGON DENGAN LUASAN (Hektar) */
/* ============================================ */

.polygon-label {
    background: rgba(44, 62, 80, 0.85);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    backdrop-filter: blur(2px);
}

.polygon-label small {
    font-size: 9px;
    opacity: 0.9;
}

/* Tooltip luas pada hover */
.polygon-area-tooltip {
    background: rgba(0, 0, 0, 0.8);
    color: #f39c12;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
}

/* ============================================ */
/* MODAL FORM STYLING */
/* ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-small {
    max-width: 400px !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    background: #ffffff;
    margin: 8% auto;
    width: 90%;
    max-width: 500px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    color: white;
    border-radius: 20px 20px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.modal-close, .modal-close-split {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover, .modal-close-split:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.modal-body {
    padding: 24px;
}

.warning-text {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.form-group .required {
    color: #e74c3c;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.polygon-preview {
    background: #f8f9fa;
    border-radius: 16px;
    margin-top: 20px;
    overflow: hidden;
    border: 1px solid #e9ecef;
}

.preview-header {
    background: #e9ecef;
    padding: 10px 16px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
}

.preview-content {
    padding: 12px 16px;
}

.preview-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 13px;
}

.preview-row:last-child {
    border-bottom: none;
}

.preview-label {
    color: #6c757d;
}

.preview-value {
    font-weight: 500;
    color: #2c3e50;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px 24px 24px;
    border-top: 1px solid #e9ecef;
}

.btn-cancel-modal {
    padding: 10px 24px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: #6c757d;
}

.btn-cancel-modal:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.btn-save-modal {
    padding: 10px 28px;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    border: none;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-save-modal:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.3);
}

.btn-save-modal:active {
    transform: translateY(0);
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================ */
/* TOAST NOTIFICATION */
/* ============================================ */

.toast-notification {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #2c3e50;
    color: white;
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2100;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-notification.success {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.toast-notification.error {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
}

.toast-notification.warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

/* Cursor untuk mode split */
.split-mode-cursor, .split-mode-cursor * {
    cursor: crosshair !important;
}

/* Responsive Modal */
@media (max-width: 600px) {
    .modal-content {
        margin: 20% auto;
        width: 95%;
    }
    
    .modal-header {
        padding: 16px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 12px 20px 20px 20px;
    }
}