/* Dice Sample Space Simulation Styles - MathsVault Design System */

/* Import site's base styles */
@import url('/css/styles.css');

/* Import 3D dice styles */
@import url('/assets/css_graphics/dice/dice.css');

/* Override dice CSS background and alignment */
body {
    background: #f8f9fa !important;
    display: block !important;
    justify-content: unset !important;
    align-items: unset !important;
    min-height: auto !important;
    perspective: unset !important;
    text-align: left !important;
}

/* Ensure proper page layout */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #f8f9fa !important;
}

/* Override any centering from dice CSS */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    text-align: left !important;
}

.container p {
    color: black !important;
}

.controls {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    flex-wrap: wrap;
    align-items: end;
    border: 2px solid var(--primary);
    box-shadow: 0 4px 15px rgba(201, 12, 15, 0.1);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: var(--primary);
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-size: 16px;
}

.control-group select,
.control-group input {
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    transition: all 0.3s ease;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(201, 12, 15, 0.1);
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    height: fit-content;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    text-transform: capitalize;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #a00a0c 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(201, 12, 15, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #a00a0c 0%, var(--primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 12, 15, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary) 0%, #e6a500 100%);
    color: var(--dark);
    box-shadow: 0 4px 15px rgba(250, 183, 25, 0.3);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #e6a500 0%, var(--secondary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(250, 183, 25, 0.4);
}

.simulation-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.simulation-container p {
    color: var(--text);
    margin-bottom: 20px;
    text-align: center;
    font-family: "Roboto", sans-serif;
    line-height: 1.6;
}

.dice-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 40px;
    background: white;
    border: 3px solid var(--primary);
    border-radius: 16px;
    color: var(--primary);
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 8px 25px rgba(201, 12, 15, 0.2);
    position: relative;
    overflow: hidden;
}

/* 3D Dice Integration */
.dice-container {
    perspective: 1000px;
    width: 120px;
    height: 120px;
}

.dice {
    position: relative;
    width: 120px;
    height: 120px;
    transform-style: preserve-3d;
    transform: rotateX(0deg) rotateY(0deg);
    margin: 0 auto;
}

.dice.rolling {
    animation: diceRoll 0.8s ease-in-out;
}

@keyframes diceRoll {
    0% { 
        transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); 
    }
    25% { 
        transform: rotateX(180deg) rotateY(90deg) rotateZ(45deg); 
    }
    50% { 
        transform: rotateX(360deg) rotateY(180deg) rotateZ(90deg); 
    }
    75% { 
        transform: rotateX(540deg) rotateY(270deg) rotateZ(135deg); 
    }
    100% { 
        transform: rotateX(720deg) rotateY(360deg) rotateZ(180deg); 
    }
}

.face {
    position: absolute;
    width: 120px;
    height: 120px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 2px solid #333;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        inset 0 0 20px rgba(0,0,0,0.1),
        0 10px 30px rgba(0,0,0,0.3);
}

/* Face positioning for 3D dice */
.front { transform: translateZ(60px); }
.right { transform: rotateY(90deg) translateZ(60px); }
.top { transform: rotateX(90deg) translateZ(60px); }
.bottom { transform: rotateX(-90deg) translateZ(60px); }
.left { transform: rotateY(-90deg) translateZ(60px); }
.back { transform: translateZ(-60px) rotateY(180deg); }

.dot {
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, #333 0%, #000 100%);
    border-radius: 50%;
    box-shadow: 
        inset 0 2px 4px rgba(255,255,255,0.3),
        0 2px 4px rgba(0,0,0,0.5);
}

/* White dice styling */
.white-dice .face {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 2px solid #333;
}

.white-dice .dot {
    background: radial-gradient(circle, #333 0%, #000 100%);
}

/* Red dice styling */
.red-dice .face {
    background: linear-gradient(145deg, #dc2626, #b91c1c);
    border: 2px solid #991b1b;
}

.red-dice .dot {
    background: radial-gradient(circle, #ffffff 0%, #f3f4f6 100%);
}

/* Black dice styling */
.black-dice .face {
    background: linear-gradient(145deg, #1f2937, #111827);
    border: 2px solid #000000;
    box-shadow: 
        inset 0 0 20px rgba(0,0,0,0.2),
        0 10px 30px rgba(0,0,0,0.4);
}

.black-dice .dot {
    background: radial-gradient(circle, #ffffff 0%, #f3f4f6 100%);
    box-shadow: 
        inset 0 2px 4px rgba(0,0,0,0.1),
        0 2px 4px rgba(0,0,0,0.3);
}

.operation-display,
.equals {
    font-size: 36px;
    font-weight: bold;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.result {
    font-size: 36px;
    font-weight: bold;
    min-width: 80px;
    text-align: center;
    background: rgba(255,255,255,0.2);
    padding: 15px 25px;
    border-radius: 12px;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.3);
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.actual-results,
.theoretical-results {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(201, 12, 15, 0.1);
    transition: all 0.3s ease;
}

.actual-results:hover,
.theoretical-results:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 12, 15, 0.15);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.actual-results h3,
.theoretical-results h3 {
    margin: 0;
    color: var(--primary);
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-size: 20px;
    font-weight: bold;
}

.view-toggle {
    display: flex;
    gap: 5px;
    background: #f8f9fa;
    padding: 4px;
    border-radius: 8px;
    border: 2px solid var(--primary);
}

.toggle-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    background: transparent;
    color: var(--primary);
}

.toggle-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(201, 12, 15, 0.3);
}

.sample-space {
    margin: 20px 0;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    max-width: 500px;
    overflow-x: auto;
}

.sample-space-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: fixed;
}

.sample-space-table th,
.sample-space-table td {
    border: 2px solid var(--primary);
    padding: 8px;
    text-align: center;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    width: 60px;
    height: 60px;
    vertical-align: middle;
}

.sample-space-table th {
    background: var(--primary);
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.sample-space-table td {
    background: white;
    font-weight: 600;
    position: relative;
}

.sample-space-table td:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(201, 12, 15, 0.3);
    transition: all 0.3s ease;
}

.sample-space-table td.highlight {
    background: var(--secondary);
    color: var(--dark);
    font-weight: bold;
}

.sample-space-table .result-value {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 2px;
}

.sample-space-table .count {
    font-size: 12px;
    color: #666;
    margin-bottom: 2px;
}

.sample-space-table .percentage {
    font-size: 10px;
    color: #999;
}

.sample-space-table td.highlight .count,
.sample-space-table td.highlight .percentage {
    color: var(--dark);
}

.statistics {
    background: linear-gradient(135deg, var(--secondary) 0%, #e6a500 100%);
    padding: 20px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--dark);
    box-shadow: 0 4px 15px rgba(250, 183, 25, 0.2);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-weight: 500;
}

.stat-item:last-child {
    margin-bottom: 0;
    font-weight: bold;
    border-top: 2px solid var(--dark);
    padding-top: 8px;
    font-size: 16px;
}

.evaluation-section {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(201, 12, 15, 0.1);
    margin-top: 30px;
}

.evaluation-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--secondary);
    padding-bottom: 10px;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px 8px 0 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    background: #f8f9fa;
    color: var(--primary);
    border: 2px solid transparent;
}

.tab-btn:hover {
    background: var(--secondary);
    color: var(--dark);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(201, 12, 15, 0.3);
}

.tab-content {
    position: relative;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.tab-panel h3 {
    margin-top: 0;
    color: var(--primary);
    border-bottom: 3px solid var(--secondary);
    padding-bottom: 15px;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-size: 20px;
    font-weight: bold;
}

.comparison {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.comparison h3 {
    margin-top: 0;
    color: var(--primary);
    border-bottom: 3px solid var(--secondary);
    padding-bottom: 15px;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-size: 20px;
    font-weight: bold;
}

.comparison-chart {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.comparison-item {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    box-shadow: 0 2px 8px rgba(201, 12, 15, 0.1);
}

.comparison-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(201, 12, 15, 0.2);
}

.comparison-item .value {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
}

.comparison-item .label {
    font-size: 12px;
    color: var(--dark);
    margin-top: 5px;
    font-weight: 500;
}

.comparison-item .actual {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: var(--primary);
}

.comparison-item .theoretical {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border-color: var(--secondary);
}

.comparison-item .difference {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-color: var(--secondary);
}

/* Distribution Graph Styles */
.distribution-graph {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.graph-container {
    display: flex;
    align-items: end;
    height: 300px;
    border-left: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
    padding: 10px;
    position: relative;
    background: white;
}

.y-axis-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-weight: bold;
    color: var(--primary);
    margin-right: 10px;
    font-size: 14px;
    min-width: 30px;
    text-align: center;
    position: absolute;
    left: -60px;
    top: 50%;
    transform: translateY(-50%);
}

.graph-area {
    flex: 1;
    display: flex;
    align-items: end;
    gap: 3px;
    height: 100%;
    min-height: 250px;
    padding: 0 5px;
}

.bar {
    background: linear-gradient(135deg, var(--primary) 0%, #a00a0c 100%);
    border-radius: 4px 4px 0 0;
    min-width: 25px;
    width: 100%;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: end;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 12px;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    min-height: 2px;
}

.bar:hover {
    background: linear-gradient(135deg, var(--secondary) 0%, #e6a500 100%);
    color: var(--dark);
    transform: scaleY(1.05);
    box-shadow: 0 4px 15px rgba(201, 12, 15, 0.3);
}

.bar-label {
    position: absolute;
    bottom: -31px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: bold;
    color: var(--primary);
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

.x-axis-label {
    text-align: center;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-weight: bold;
    color: var(--primary);
    margin-top: 16px;
    font-size: 14px;
}

/* Graph Legend */
.graph-legend {
    display: flex;
    justify-content: center;
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-line {
    width: 30px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.theoretical {
    background: #FAB719;
    border: none;
    position: relative;
}

.legend-line.theoretical::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        to right,
        #FAB719 0px,
        #FAB719 3px,
        transparent 3px,
        transparent 6px
    );
}

.legend-label {
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}

/* Results List for complex operations */
.results-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin: 20px 0;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
}

.result-item {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    transition: all 0.3s ease;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    box-shadow: 0 2px 8px rgba(201, 12, 15, 0.1);
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(201, 12, 15, 0.2);
}

.result-item.highlight {
    background: linear-gradient(135deg, var(--secondary) 0%, #e6a500 100%);
    border-color: var(--secondary);
    color: var(--dark);
}

.result-item .result-value {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
}

.result-item.highlight .result-value {
    color: var(--dark);
}

.result-item .result-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 2px;
}

.result-item .result-percentage {
    font-size: 12px;
    color: #666;
}

/* 3D Dice Face Layouts */
/* Face 2 - Two dots */
.right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 15px;
    padding: 20px;
}

.right .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.right .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 2;
}

/* Face 3 - Three dots */
.top {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 10px;
    padding: 15px;
}

.top .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.top .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 2;
}

.top .dot:nth-child(3) {
    grid-column: 3;
    grid-row: 3;
}

/* Face 4 - Four dots */
.bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 15px;
    padding: 20px;
}

.bottom .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.bottom .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

.bottom .dot:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
}

.bottom .dot:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
}

/* Face 5 - Five dots */
.left {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 10px;
    padding: 15px;
}

.left .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.left .dot:nth-child(2) {
    grid-column: 3;
    grid-row: 1;
}

.left .dot:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

.left .dot:nth-child(4) {
    grid-column: 1;
    grid-row: 3;
}

.left .dot:nth-child(5) {
    grid-column: 3;
    grid-row: 3;
}

/* Face 6 - Six dots */
.back {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 15px;
    padding: 20px;
}

.back .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.back .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

.back .dot:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
}

.back .dot:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
}

.back .dot:nth-child(5) {
    grid-column: 1;
    grid-row: 3;
}

.back .dot:nth-child(6) {
    grid-column: 2;
    grid-row: 3;
}

/* Responsive design */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .dice-display {
        flex-direction: column;
        gap: 20px;
    }
    
    .dice-container {
        width: 100px;
        height: 100px;
    }
    
    .dice {
        width: 100px;
        height: 100px;
    }
    
    .face {
        width: 100px;
        height: 100px;
    }
    
    .dot {
        width: 15px;
        height: 15px;
    }
    
    .operation-display,
    .equals,
    .result {
        font-size: 28px;
    }
}

/* Loading animation */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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