/* CSS styles for the Pole Manager web mapping app */

html, body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    height: 100vh;
    overflow: hidden; /* Prevent scrollbars on main window */
}

body {
    display: flex;
    flex-direction: column;
}

#map {
    height: 75vh;
    width: 100vw;
    flex-shrink: 0;
}

#permits-container {
    height: 25vh;
    width: 100vw;
    background: #f5f5f5;
    border-top: 2px solid #ddd;
    display: flex;
    flex-direction: column;
}

#permits-header {
    background: #e0e0e0;
    padding: 10px;
    border-bottom: 1px solid #ccc;
    font-weight: bold;
    flex-shrink: 0;
}

.status-legend {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

#permits-table-container {
    flex: 1;
    overflow: auto;
    padding: 5px;
}

#permits-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: white;
}

#permits-table th,
#permits-table td {
    border: 1px solid #ddd;
    padding: 4px 8px;
    text-align: left;
    white-space: nowrap;
}

#permits-table th {
    background: #f0f0f0;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
}

#permits-table tr:nth-child(even) {
    background: #f9f9f9;
}

#permits-table tr:hover {
    background: #e6f3ff;
    cursor: pointer;
}

.permit-row {
    transition: background-color 0.2s ease;
    cursor: pointer;
    user-select: none;
}

.permit-row:hover {
    background: #e6f3ff !important;
}

/* Ensure cell background colors show through */
#permits-table td {
    position: relative;
}

/* Missing data indicator styling */
.missing-data-cell {
    background-color: #ffcccc !important;
}

/* Received permit with non-blue poles styling */
.received-non-blue-status {
    background-color: #ffff99 !important; /* Light yellow */
    border-left: 4px solid #ffa500 !important; /* Orange left border for emphasis */
}

.loading-permits {
    padding: 20px;
    text-align: center;
    font-style: italic;
    color: #666;
}

.map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: white;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    min-width: 280px;
    max-width: 320px;
    transition: all 0.3s ease;
}

.map-controls.collapsed {
    width: 40px;
    min-width: 40px;
    padding: 10px;
    overflow: hidden;
}

.map-controls.collapsed .controls-content {
    display: none;
}

.toggle-panel-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 3px;
    width: 25px;
    height: 25px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.toggle-panel-btn:hover {
    background: #0056b3;
}

.map-controls.collapsed .toggle-panel-btn {
    position: static;
    width: 30px;
    height: 30px;
    font-size: 14px;
}

.map-controls h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.project-dropdown {
    width: 100%;
    padding: 8px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.project-info {
    margin-top: 10px;
    font-size: 12px;
    color: #666;
}

.aep-section {
    border-top: 1px solid #ddd;
    margin-top: 15px;
    padding-top: 15px;
}

.collapsible-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: bold;
}

.collapsible-header:hover {
    color: #007bff;
}

#permit-header {
    cursor: pointer;
}

.collapse-toggle {
    margin-right: 8px;
    font-size: 12px;
    transition: transform 0.2s ease;
    width: 12px;
    text-align: center;
}

.collapse-toggle.expanded {
    transform: rotate(90deg);
}

.collapsible-content {
    overflow: hidden;
    padding-top: 20px;
}

.collapsible-content.collapsed {
    display: none;
}

.permit-subsection {
    margin-bottom: 10px;
}

.aep-button {
    width: 100%;
    padding: 10px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 10px;
}

.aep-button:hover {
    background: #0056b3;
}

.aep-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.aep-status {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.aep-status.no-data {
    color: #dc3545;
}

.aep-status.has-data {
    color: #28a745;
}

.aep-loading {
    font-style: italic;
    color: #666;
}

/* Additional styles for AEP validation states */
.aep-found {
    color: #28a745 !important;
    font-weight: bold !important;
}

.aep-not-found {
    color: #dc3545 !important;
    font-weight: bold !important;
}

.aep-date-match {
    color: #28a745 !important;
    font-weight: bold !important;
}

.aep-date-mismatch {
    color: #dc3545 !important;
    font-weight: bold !important;
}

.aep-date-error {
    color: #fd7e14 !important;
    font-weight: bold !important;
}

.aep-date-unknown {
    color: #6c757d !important;
    font-style: italic !important;
}

.loading-text {
    font-style: italic;
    color: #999;
}

.leaflet-popup-content {
    margin: 8px 12px;
    line-height: 1.4;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    margin: 8px 12px;
    font-family: Arial, sans-serif;
}

.leaflet-popup-content strong {
    color: #333;
}

/* Approved poles styling */
.leaflet-popup-content strong:first-child {
    color: #00FFFF;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Permit row selection styles */
.permit-row.selected {
    background-color: #007bff !important;
    color: white !important;
}

.permit-row.selected:hover {
    background-color: #0056b3 !important;
}

/* Document Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 0;
    border: 1px solid #888;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background-color: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close-modal {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close-modal:hover,
.close-modal:focus {
    color: #000;
}

.modal-body {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.document-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.3s;
}

.document-item:hover {
    background-color: #f8f9fa;
}

.document-item:last-child {
    border-bottom: none;
}

.document-name {
    font-weight: 500;
    color: #007bff;
    margin-bottom: 4px;
}

.document-extension {
    font-size: 12px;
    color: #666;
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.document-count {
    text-align: center;
    padding: 4px 8px;
    border-radius: 4px;
}

.document-count.has-documents {
    background-color: #e3f2fd;
    color: #1976d2;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
}

.document-count.has-documents:hover {
    background-color: #bbdefb;
}

.document-count:not(.has-documents) {
    color: #666;
}

.document-item.downloading {
    background-color: #fff3cd;
    color: #856404;
}

.document-item.downloading .document-name {
    color: #856404;
    font-style: italic;
}

.document-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.document-info {
    flex: 1;
}

.document-buttons {
    display: flex;
    gap: 8px;
    margin-left: 10px;
}

.parse-button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.parse-button:hover {
    background-color: #218838;
}

.parse-button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.parse-button.parsing {
    background-color: #ffc107;
    color: #212529;
}

.parse-oncor-button {
    background-color: #17a2b8;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.parse-oncor-button:hover {
    background-color: #138496;
}

.parse-oncor-button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.parse-oncor-button.parsing {
    background-color: #ffc107;
    color: #212529;
}

/* Copy button styling */
.copy-button {
    background: none;
    border: none;
    color: #007bff;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    margin-left: 5px;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.copy-button:hover {
    background-color: #e6f3ff;
    color: #0056b3;
}

.copy-button:active {
    background-color: #cce7ff;
}

.copy-button.copied {
    color: #28a745;
    background-color: #d4edda;
}

/* Pole approval buttons styling */
.pole-approval-section {
    border-top: 1px solid #ddd;
    margin-top: 15px;
    padding-top: 15px;
}

.pole-approval-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pole-approval-button {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: 500;
}

.pole-approval-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.approve-all-button {
    background-color: #28a745;
    color: white;
}

.approve-all-button:hover:not(:disabled) {
    background-color: #218838;
}

.approve-matched-button {
    background-color: #17a2b8;
    color: white;
}

.approve-matched-button:hover:not(:disabled) {
    background-color: #138496;
}

.approve-selected-button {
    background-color: #ffc107;
    color: #212529;
}

.approve-selected-button:hover:not(:disabled) {
    background-color: #e0a800;
}

.pole-approval-status {
    font-size: 11px;
    color: #666;
    margin-top: 5px;
    min-height: 15px;
}

/* Unassigned poles warning styles */
.pole-warning-section {
    border-top: 1px solid #ddd;
    margin-top: 15px;
    padding-top: 15px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
}

.pole-warning-message {
    font-size: 12px;
    color: #856404;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 100%;
}

.pole-warning-count {
    font-weight: bold;
    color: #dc3545;
}

/* Custom marker styles if needed */
.custom-marker {
    background-color: #ff6b6b;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Sync button styling */
.sync-permit-button {
    background-color: #17a2b8;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.sync-permit-button:hover {
    background-color: #138496;
}

.sync-permit-button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.actions-cell {
    text-align: center;
    padding: 4px 8px !important;
    min-width: 70px;
    background-color: #f8f9fa !important;
}

.actions-cell:hover {
    background-color: #e9ecef !important;
}

/* Loading indicator */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    z-index: 2000;
}

/* Login Modal Styles */
.login-modal {
    z-index: 9999;
    background-color: rgba(0, 0, 0, 0.7);
}

.login-modal-content {
    margin: 15% auto;
    width: 90%;
    max-width: 400px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    color: white;
}

.login-modal .modal-header {
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    text-align: center;
    padding: 25px 20px 20px 20px;
}

.login-modal .modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 300;
    letter-spacing: 1px;
}

.login-modal .modal-body {
    padding: 30px;
}

.login-field {
    margin-bottom: 20px;
}

.login-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
}

.login-field input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.login-field input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.login-field input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.login-actions {
    margin-top: 30px;
    text-align: center;
}

.login-button {
    width: 100%;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
}

.login-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.login-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.login-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-error {
    margin-top: 15px;
    padding: 12px;
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.4);
    border-radius: 6px;
    color: #ffcccb;
    font-size: 14px;
    text-align: center;
}

/* App overlay for dimming */
.app-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    display: none;
    backdrop-filter: blur(2px);
}

/* Body state during login */
body.login-active {
    overflow: hidden;
}

body.login-active #map,
body.login-active #permits-container,
body.login-active .map-controls {
    filter: blur(3px);
    pointer-events: none;
    user-select: none;
}

/* Graph Analysis Styles */

/* Graph Toggle Control Button */
.leaflet-control-graph {
    background: white;
    border: 2px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 1px 5px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    user-select: none;
}

.leaflet-control-graph:hover {
    background: #f0f0f0;
    border-color: #28a745;
    color: #28a745;
}

.leaflet-control-graph.active {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

/* Segment Editing Styles */

/* Segment Edit Control Button */
.leaflet-control-segment-edit {
    background: white;
    border: 2px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 1px 5px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    user-select: none;
}

.leaflet-control-segment-edit:hover {
    background: #f0f0f0;
    border-color: #007bff;
    color: #007bff;
}

.leaflet-control-segment-edit.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

/* Pole Editing Styles */

/* Pole Edit Control Button */
.leaflet-control-pole-edit {
    background: white;
    border: 2px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 1px 5px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    user-select: none;
}

.leaflet-control-pole-edit:hover {
    background: #f0f0f0;
    border-color: #28a745;
    color: #28a745;
}

.leaflet-control-pole-edit.active {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

/* Pole Edit Mode - cursor changes are handled per-pole on hover */

/* RTC (Ready to Construct) Control Button */
.leaflet-control-rtc {
    background: white;
    border: 2px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 1px 5px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    user-select: none;
}

.leaflet-control-rtc:hover {
    background: #f0f0f0;
    border-color: #FF6B35;
    color: #FF6B35;
}

.leaflet-control-rtc.active {
    background: #FF6B35;
    border-color: #FF6B35;
    color: white;
}

/* Segment Edit Mode Cursor */
.segment-edit-cursor {
    cursor: crosshair !important;
}

.segment-edit-cursor * {
    cursor: crosshair !important;
}

/* Segment Vertex Markers */
.segment-vertex-marker {
    border: none !important;
    background: transparent !important;
}

.segment-vertex-marker-inner {
    width: 12px;
    height: 12px;
    background: transparent;
    border: 3px solid #FF6B00;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.3);
    cursor: move;
    transition: all 0.2s ease;
}

.segment-vertex-marker-inner:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(255, 107, 0, 0.5);
}

/* Graph Vertex Markers (similar to segment markers but distinct color) */
.graph-vertex-marker {
    border: none !important;
    background: transparent !important;
}

.graph-vertex-marker-inner {
    width: 12px;
    height: 12px;
    background: transparent;
    border: 3px solid #9400D3; /* Purple for graph mode distinction */
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(148, 0, 211, 0.3);
    cursor: move;
    transition: all 0.2s ease;
}

.graph-vertex-marker-inner:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(148, 0, 211, 0.5);
}

/* Pole Snap Indicator */
.pole-snap-indicator {
    z-index: 3001 !important;
    pointer-events: none !important;
}

/* Vertex Snap Indicator */
.vertex-snap-indicator {
    z-index: 3002 !important;
    pointer-events: none !important;
}

/* Segment editing temporary lines */
.segment-temp-line {
    pointer-events: none !important;
}

/* Aerial segment highlighting when selected */
.aerial-segment-selected {
    stroke: #FF6B00 !important;
    stroke-width: 5 !important;
    stroke-opacity: 1.0 !important;
}

/* Edit mode information panel */
.segment-edit-info {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 12px;
    z-index: 1000;
    max-width: 300px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.segment-edit-info.active {
    opacity: 1;
    transform: translateY(0);
}

.segment-edit-info h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    color: #FF6B00;
}

.segment-edit-info p {
    margin: 3px 0;
    line-height: 1.3;
}

/* Tooltips for segment editing */
.leaflet-tooltip.segment-edit-tooltip {
    background: rgba(255, 107, 0, 0.9);
    border: 1px solid #FF6B00;
    color: white;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: bold;
}

.leaflet-tooltip.segment-edit-tooltip:before {
    border-top-color: #FF6B00;
}

/* Pole snap feedback tooltip */
.leaflet-tooltip.pole-snap-tooltip {
    background: rgba(0, 255, 0, 0.9);
    border: 1px solid #00FF00;
    color: #000;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: bold;
}

.leaflet-tooltip.pole-snap-tooltip:before {
    border-top-color: #00FF00;
}

/* Disable normal segment hover effects when in edit mode */
.segment-edit-cursor .leaflet-interactive:hover {
    stroke-width: 3 !important;
    stroke-opacity: 0.8 !important;
}

/* Visual feedback for segments that can be edited (aerial only) */
.aerial-segment-editable:hover {
    stroke-width: 4 !important;
    stroke-opacity: 1.0 !important;
    cursor: pointer !important;
}

/* Non-editable segment indication */
.underground-segment-non-editable {
    cursor: not-allowed !important;
}

/* Segment editing help text */
.segment-edit-help {
    position: absolute;
    top: 50px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px 15px;
    font-size: 12px;
    max-width: 250px;
    z-index: 999;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease;
}

.segment-edit-help.visible {
    opacity: 1;
    transform: translateX(0);
}

.segment-edit-help h5 {
    margin: 0 0 8px 0;
    color: #FF6B00;
    font-size: 13px;
}

.segment-edit-help ul {
    margin: 0;
    padding-left: 15px;
    list-style-type: disc;
}

.segment-edit-help li {
    margin: 3px 0;
    line-height: 1.4;
}

/* Basemap toggle button styling */
.basemap-toggle-control {
    margin-bottom: 10px; /* Position above permits table */
}

.basemap-toggle-button {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    min-width: 70px;
    text-align: center;
}

.basemap-toggle-button:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #007cff;
    color: #007cff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

.basemap-toggle-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
