/* Push-Relabel Algorithm Visualizer Styles */

/* ================================
   Base Styles
   ================================ */
.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Arial', sans-serif;
}

.game-container h1 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
    font-size: 28px;
}

/* ================================
   Main Layout
   ================================ */
.main-layout {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.control-panel {
    width: 300px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    height: fit-content;
}

.canvas-container {
    flex: 1;
    position: relative;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

/* ================================
   Control Panel Sections
   ================================ */
.panel-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #dee2e6;
}

.panel-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.panel-section h3 {
    font-size: 16px;
    color: #495057;
    margin-bottom: 10px;
}

/* Tab Buttons */
.tab-buttons {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    font-size: 14px;
}

.tab-btn:hover {
    background: #e9ecef;
}

.tab-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Tool Buttons */
.tool-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    border: 1px solid #dee2e6;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    text-align: left;
    font-size: 14px;
}

.tool-btn:hover {
    background: #e9ecef;
    transform: translateX(2px);
}

.tool-btn.active {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #1976d2;
}

.tool-btn .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* 削除モード時のカーソル */
#graph-canvas.delete-mode {
    cursor: not-allowed !important;
}

#graph-canvas.delete-mode .node,
#graph-canvas.delete-mode .edge {
    cursor: pointer !important;
}

#graph-canvas.delete-mode .node:hover circle {
    fill: #ffcccc;
    stroke: #ff0000;
}

#graph-canvas.delete-mode .edge:hover {
    stroke: #ff0000;
    stroke-width: 5px;
}

/* 移動モード時のカーソル */
#graph-canvas[style*="grab"] .node {
    cursor: grab !important;
}

#graph-canvas[style*="grab"] .node:active {
    cursor: grabbing !important;
}

/* ノード移動時のスタイル */
.node.dragging {
    opacity: 0.8;
}

.node.dragging circle {
    stroke-width: 4px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.action-btn {
    padding: 8px 12px;
    border: 1px solid #6c757d;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    font-size: 13px;
}

.action-btn:hover {
    background: #6c757d;
    color: white;
}

/* Algorithm Controls */
.algorithm-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.primary-btn, .secondary-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn {
    background: #28a745;
    color: white;
}

.primary-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.secondary-btn {
    background: #6c757d;
    color: white;
}

.secondary-btn:hover {
    background: #5a6268;
}

/* Status Display */
.status-display {
    background: white;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 14px;
}

.status-item span:first-child {
    color: #6c757d;
}

.status-item span:last-child {
    font-weight: bold;
    color: #495057;
}

/* ================================
   Text Input Mode
   ================================ */
.text-input-area label {
    display: block;
    font-size: 13px;
    color: #495057;
    margin-top: 10px;
    margin-bottom: 5px;
}

.text-input-area textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    resize: vertical;
}

.source-sink-input {
    display: flex;
    gap: 10px;
}

.source-sink-input input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
}

.text-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ================================
   Preset Mode
   ================================ */
.preset-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preset-btn {
    padding: 12px 15px;
    border: 1px solid #dee2e6;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    text-align: left;
    font-size: 14px;
}

.preset-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* ================================
   Canvas Styles
   ================================ */
#graph-canvas {
    background: white;
    cursor: crosshair;
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 600px;
}

/* Grid */
#grid line {
    stroke: #f0f0f0;
    stroke-width: 1;
}

/* Nodes */
.node {
    cursor: move;
}

.node circle {
    fill: #4A90E2;
    stroke: #357ABD;
    stroke-width: 3px;
    transition: all 0.3s;
}

.node.source circle {
    fill: #7ED321;
    stroke: #5FA019;
}

.node.sink circle {
    fill: #D0021B;
    stroke: #A00116;
}

.node.active circle {
    stroke: #F5A623;
    stroke-width: 5px;
    animation: pulse 1s infinite;
}

.node text {
    fill: white;
    font-size: 16px;
    font-weight: bold;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
}

.node .info {
    font-size: 11px;
    fill: #333;
}

.node .height {
    text-anchor: middle;
}

.node .excess {
    text-anchor: middle;
}

/* Edges */
.edge {
    stroke: #333;
    stroke-width: 3px;
    fill: none;
    marker-end: url(#arrowhead);
    cursor: pointer;
    transition: all 0.3s;
}

.edge:hover {
    stroke-width: 4px;
}

.edge.saturated {
    stroke: #D0021B;
    stroke-width: 5px;
    marker-end: url(#arrowhead-saturated);
}

.edge.active {
    stroke: #F5A623;
    stroke-width: 5px;
    marker-end: url(#arrowhead-active);
    animation: flow-animation 1s infinite;
}

/* Flow animation for active edges */
@keyframes flow-animation {
    0% {
        stroke-dasharray: 10 5;
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dasharray: 10 5;
        stroke-dashoffset: 15;
    }
}

.edge-label {
    font-size: 14px;
    font-weight: bold;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
}

.edge-label rect {
    fill: white;
    stroke: none;
}

.edge-label text {
    fill: #333;
}

/* Capacity Editor */
.capacity-editor {
    position: absolute;
    z-index: 100;
    background: white;
    border: 2px solid #007bff;
    border-radius: 4px;
    padding: 2px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.capacity-editor input {
    width: 60px;
    padding: 4px 6px;
    border: none;
    outline: none;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}

/* ================================
   Step Control Bar
   ================================ */
.step-control-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 20px;
}

.step-buttons {
    display: flex;
    gap: 10px;
}

.step-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #dee2e6;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    font-size: 18px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-btn:hover:not(:disabled) {
    background: #e9ecef;
}

.step-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.speed-control {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.speed-control span {
    font-size: 14px;
    color: #495057;
}

.speed-control input[type="range"] {
    flex: 1;
    height: 6px;
    background: #dee2e6;
    outline: none;
    border-radius: 3px;
}

/* ================================
   Step Info Display
   ================================ */
.step-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.step-info h3 {
    margin-bottom: 10px;
    color: #333;
}

.step-info p {
    font-size: 16px;
    color: #495057;
    margin-bottom: 15px;
}

.step-details {
    background: white;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    font-size: 14px;
    line-height: 1.6;
}

/* ================================
   Result Panel
   ================================ */
.result-panel {
    background: #e8f5e9;
    border: 2px solid #4caf50;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.result-panel h2 {
    color: #2e7d32;
    margin-bottom: 15px;
}

.result-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.result-item {
    background: white;
    padding: 10px 15px;
    border-radius: 4px;
    border: 1px solid #a5d6a7;
}

.result-item strong {
    color: #1b5e20;
}

.result-paths {
    grid-column: 1 / -1;
    background: white;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #a5d6a7;
}

.flow-path {
    padding: 5px 0;
    color: #2e7d32;
    font-family: 'Courier New', monospace;
}

/* ================================
   Help Section
   ================================ */
.help-section {
    margin-top: 30px;
}

.help-section details {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
}

.help-section summary {
    cursor: pointer;
    font-weight: bold;
    color: #495057;
    outline: none;
}

.help-content {
    margin-top: 15px;
    line-height: 1.6;
}

.help-content h3, .help-content h4 {
    color: #333;
    margin-top: 15px;
    margin-bottom: 10px;
}

.help-content ul {
    margin-left: 20px;
}

.help-content li {
    margin-bottom: 5px;
}

/* ================================
   Animations
   ================================ */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ================================
   Utility Classes
   ================================ */
.hidden {
    display: none !important;
}

.mode-content {
    display: block;
}

.mode-content.hidden {
    display: none;
}

/* ================================
   Responsive Design
   ================================ */
@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }
    
    .control-panel {
        width: 100%;
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
    }
    
    .result-content {
        grid-template-columns: 1fr;
    }
}