/* Perceptron Demo Custom Styles */

/* Override parent demo-area flex to make vertical stacking */
.demo-area {
    display: block !important;
}

/* Main container - 2/3 + 1/3 flex layout */
.gd-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}

.view-panel {
    flex: 0 0 calc((100% - 20px) * 0.6667);
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.view-title {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 10px;
    color: #2c3e50;
    text-align: center;
}

.step-btn, .reset-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.step-btn {
    background: #3498db;
    color: white;
}

.step-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.reset-btn {
    background: #95a5a6;
    color: white;
}

.reset-btn:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(149, 165, 166, 0.3);
}

/* Controls sidebar - styled panel */
.controls {
    flex: 0 0 calc((100% - 20px) * 0.3333);
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #f5f7fa;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid #dee2e6;
    box-sizing: border-box;
}

.control-group {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: #2c3e50;
}

.control-group label.control-label-strong {
    margin-bottom: 10px;
    font-weight: 700;
}

/* Dataset Selection Grid - styled like lec02c feature boxes */
.dataset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.dataset-box {
    padding: 15px 10px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0.4;
    filter: grayscale(50%);
}

.dataset-icon {
    font-size: 28px;
    line-height: 1;
}

.dataset-label {
    font-size: 13px;
    font-weight: 600;
}

.dataset-box:hover {
    transform: translateY(-2px);
    opacity: 0.6;
}

/* Clean dataset - Green */
.dataset-clean {
    background: linear-gradient(135deg, #5cb85c, #4cae4c);
    color: white;
}

.dataset-clean.active {
    opacity: 1;
    filter: grayscale(0%);
    border-color: #5cb85c;
}

.dataset-clean.active:hover {
    background: linear-gradient(135deg, #4cae4c, #3c9e3c);
}

/* XOR dataset - Purple */
.dataset-xor {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
}

.dataset-xor.active {
    opacity: 1;
    filter: grayscale(0%);
    border-color: #9b59b6;
}

.dataset-xor.active:hover {
    background: linear-gradient(135deg, #8e44ad, #7e349d);
}

/* Class Selection */
.class-selector {
    display: flex;
    gap: 8px;
}

.class-btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    border: 2px solid transparent;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.6;
}

#class0Btn {
    background: #3498db;
}

#class1Btn {
    background: #e74c3c;
}

.class-btn:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

.class-btn.active {
    opacity: 1;
    border-color: #2c3e50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Clear Data Button */
.action-btn {
    width: 100%;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid #e74c3c;
    background: white;
    color: #e74c3c;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #e74c3c;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

/* Readout Panel */
.readout-panel {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
}

.readout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.readout-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 4px 0;
}

.readout-label {
    color: #555;
    font-weight: 500;
}

.readout-value {
    color: #2c3e50;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

/* History Container - matches gradient descent exactly */
.history-container {
    margin-top: 10px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 0;
    padding: 8px;
}

.history-title {
    font-weight: bold;
    font-size: 12px;
    color: #333;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    max-height: 200px;
}

.history-scroll::-webkit-scrollbar {
    height: 8px;
}

.history-scroll::-webkit-scrollbar-track {
    background: #e9ecef;
}

.history-scroll::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 4px;
}

.history-scroll::-webkit-scrollbar-thumb:hover {
    background: #495057;
}

.history-table {
    width: auto;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.history-table tbody th {
    background: #343a40;
    color: white;
    padding: 4px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    border: 1px solid #23272b;
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 80px;
}

.history-table tbody td {
    padding: 3px 8px;
    text-align: center;
    border: 1px solid #dee2e6;
    background: white;
    font-family: monospace;
    font-size: 12px;
    min-width: 70px;
}

.history-table tbody td.current-iteration {
    background: #fff3cd;
    border: 2px solid #ffc107;
    font-weight: bold;
}

.history-table tbody tr:hover td {
    background: #e9ecef;
}

.history-table tbody tr:hover td.current-iteration {
    background: #ffe69c;
}

.history-table tbody tr:nth-child(odd) td {
    background: #f8f9fa;
}

.history-table tbody tr:nth-child(odd) td.current-iteration {
    background: #fff3cd;
}

.history-table tbody tr:nth-child(odd):hover td {
    background: #e2e6ea;
}

.history-table tbody tr:nth-child(odd):hover td.current-iteration {
    background: #ffe69c;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .gd-container {
        flex-direction: column;
    }

    .view-panel,
    .controls {
        flex: 1 1 100%;
        width: 100%;
    }

    .dataset-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .dataset-grid {
        grid-template-columns: 1fr;
    }

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