body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
}

/* Modal styles for popups */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fff;
    margin: 2% auto;
    padding: 10px;
    border-radius: 8px;
    width: 90%;
    height: 90%;
    max-width: 1400px;
    max-height: 900px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

body.dark-mode .modal-content {
    background-color: #2a2a2a;
    color: #fff;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

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

body.dark-mode .modal-close:hover {
    color: #fff;
}

.modal-title {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 20px;
    font-weight: bold;
    flex-shrink: 0;
}

#modal-body {
    width: 100%;
    height: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
}

.modal-toolbar {
    background-color: #f0f0f0;
    border-bottom: 1px solid #ccc;
    padding: 6px;
    display: flex;
    gap: 6px;
    margin-bottom: 0;
    flex-shrink: 0;
}

body.dark-mode .modal-toolbar {
    background-color: #3a3a3a;
    border-bottom: 1px solid #555;
}

.toolbar-btn {
    background: #fff;
    border: 1px solid #ccc;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 12px;
}

body.dark-mode .toolbar-btn {
    background: #555;
    border: 1px solid #666;
    color: #fff;
}

.toolbar-btn:hover {
    background: #e0e0e0;
}

body.dark-mode .toolbar-btn:hover {
    background: #666;
}

.modal-plot-container {
    text-align: center;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.modal-text {
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
    font-family: "Courier New", monospace;
}

.modal-theory {
    font-size: 18px;
    line-height: 1.6;
}

/* 3D Bloch sphere container */
.bloch-3d-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.bloch-3d-label {
    position: absolute;
    font-size: 14px;
    font-weight: bold;
    color: #000;
    pointer-events: none;
    z-index: 10;
}

.bloch-3d-title {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: bold;
    color: #000;
    pointer-events: none;
    z-index: 10;
}

body.light-mode {
    background-color: #f0f0f0;
    color: #000;
}

body.dark-mode {
    background-color: #191919;
    color: #fff;
}

.app-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.top-bar {
    height: 60px;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    box-sizing: border-box;
    border-bottom: 1px solid #e0e0e0;
}

body.dark-mode .top-bar {
    background-color: #191919;
    border-bottom-color: #444;
}

body.dark-mode .header-actions .logout-btn {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: white;
    border: 1px solid #dc2626;
}

body.dark-mode .header-actions .logout-btn:hover {
    background: linear-gradient(135deg, #b91c1c, #dc2626);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-actions .logout-btn {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 6px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
    margin: 0;
}

.header-actions .logout-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
}

.logo-img {
    height: 40px;
    width: 40px;
    object-fit: contain;
    border-radius: 4px;
    margin-right: 2px;
}

.logo-text .title {
    font-size: 18px;
    font-weight: 600;
}

.logo-text .subtitle {
    font-size: 12px;
    color: #555;
}

body.dark-mode .logo-text .subtitle {
    color: #ccc;
}

.main-split {
    flex: 1;
    display: flex;
    min-height: 0;
}

.left-panel {
    width: 260px;
    background-color: #f8f9fa;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

body.dark-mode .left-panel {
    background-color: #1a1a1a;
}

.section-label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
    display: block;
    letter-spacing: 0.025em;
}

body.dark-mode .section-label {
    color: #fff;
}

.control-select,
.numeric-input,
.slider-input,
.dynamic-controls select,
.dynamic-controls input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #d0d0d0;
    background-color: #fff;
    font-size: 13px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.control-select:focus,
.numeric-input:focus,
.dynamic-controls select:focus,
.dynamic-controls input:focus {
    outline: none;
    border-color: #2c5f2d;
    box-shadow: 0 0 0 2px rgba(44, 95, 45, 0.1);
}

/* Error state for input fields */
.dynamic-controls input[type="number"].error,
.dynamic-controls input[type="text"].error {
    border-color: #dc2626 !important;
    background-color: #fee2e2 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.1) !important;
}

.dynamic-controls input[type="number"].error:focus,
.dynamic-controls input[type="text"].error:focus {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2) !important;
}

.dynamic-controls input[type="range"] {
    padding: 0;
    height: 6px;
    background: linear-gradient(to right, #2c5f2d 0%, #90c9a4 100%);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.dynamic-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2c5f2d;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.dynamic-controls input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2c5f2d;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.dark-mode .control-select,
body.dark-mode .numeric-input,
body.dark-mode .dynamic-controls select,
body.dark-mode .dynamic-controls input {
    background-color: #2a2a2a;
    border-color: #555;
    color: #fff;
}

body.dark-mode .control-select:focus,
body.dark-mode .numeric-input:focus,
body.dark-mode .dynamic-controls select:focus,
body.dark-mode .dynamic-controls input:focus {
    border-color: #90c9a4;
    box-shadow: 0 0 0 2px rgba(144, 201, 164, 0.1);
}

body.dark-mode .dynamic-controls input[type="range"] {
    background: linear-gradient(to right, #90c9a4 0%, #2c5f2d 100%);
}

body.dark-mode .dynamic-controls input[type="range"]::-webkit-slider-thumb {
    background: #90c9a4;
    border: 2px solid #2a2a2a;
}

body.dark-mode .dynamic-controls input[type="range"]::-moz-range-thumb {
    background: #90c9a4;
    border: 2px solid #2a2a2a;
}

.dynamic-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    padding: 4px 0;
}

.radio-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0;
}

.radio-item,
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.radio-item:hover,
.checkbox-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

body.dark-mode .radio-item:hover,
body.dark-mode .checkbox-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.radio-item input[type="radio"],
.checkbox-item input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.radio-item label,
.checkbox-item label {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.form-group {
    margin-bottom: 12px;
}

.form-group .section-label {
    margin-bottom: 6px;
    display: block;
}

.slider-container {
    margin: 8px 0;
}

.slider-value {
    font-size: 12px;
    font-weight: 600;
    color: #2c5f2d;
    text-align: center;
    margin-top: 4px;
    padding: 2px 6px;
    background-color: rgba(44, 95, 45, 0.1);
    border-radius: 3px;
}

body.dark-mode .slider-value {
    color: #90c9a4;
    background-color: rgba(144, 201, 164, 0.1);
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-row input {
    flex: 1;
}

.bases-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .bases-container {
    background-color: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.1);
}

.primary-btn,
.secondary-btn,
.darkmode-btn {
    padding: 10px;
    border-radius: 5px;
    border: none;
    font-weight: bold;
    cursor: pointer;
}

.primary-btn {
    background-color: #a8d5ba;
    color: #2c5f2d;
}

.primary-btn:hover {
    background-color: #90c9a4;
}

.secondary-btn {
    background-color: #b3d4e5;
    color: #2c5f7d;
}

.secondary-btn:hover {
    background-color: #9bc4d9;
}

.darkmode-btn {
    background-color: #d3d3d3;
    color: #4a4a4a;
}

.darkmode-btn:hover {
    background-color: #bebebe;
}

.logout-btn {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
    transition: all 0.3s ease;
    border: 1px solid #dc2626;
    padding: 10px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
}

.logout-btn:hover {
    background: linear-gradient(135deg, #b91c1c, #dc2626);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    transform: translateY(-1px);
}

body.dark-mode .primary-btn {
    background-color: #2d5a3d;
    color: #fff;
    border: 1px solid #4a7c59;
}

body.dark-mode .primary-btn:hover {
    background-color: #3d6a4d;
}

body.dark-mode .secondary-btn {
    background-color: #2d4a5a;
    color: #fff;
    border: 1px solid #4a6a7c;
}

body.dark-mode .secondary-btn:hover {
    background-color: #3d5a6a;
}

body.dark-mode .darkmode-btn {
    background-color: #4a4a4a;
    color: #fff;
}


.left-panel-spacer {
    flex: 1;
}

.right-panel {
    flex: 1;
    padding: 5px;
    box-sizing: border-box;
    overflow: auto;
}

.top-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.panel-box {
    background-color: #fff;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
    padding: 4px 8px 8px 8px;
    box-sizing: border-box;
}

body.dark-mode .panel-box {
    background-color: #2a2a2a;
    border-color: #444;
}

.box-badge {
    display: inline-block;
    margin-bottom: 4px;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    background-color: #e8f4f8;
    color: #2c5f7d;
}

.console-text,
.params-text {
    margin: 0;
    font-family: "Courier New", monospace;
    font-size: 11px;
    max-height: 250px;
    overflow: auto;
}

.theory-text {
    font-size: 11px;
    max-height: 250px;
    overflow: auto;
}

.plots-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.plot-card {
    background-color: #fff;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
    padding: 4px 4px 8px 4px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: 550px;
}

body.dark-mode .plot-card {
    background-color: #2a2a2a;
    border-color: #444;
}

.plot-card .plot-badge {
    display: inline-block;
    margin: 2px 0 4px 4px;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    background-color: #e8f4f8;
    color: #2c5f7d;
    flex-shrink: 0;
}

.plot-container {
    width: 100%;
    height: 500px;
    cursor: pointer;
    overflow: hidden;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.plot-img {
    width: 100%;
    max-height: 480px;
    object-fit: contain;
    cursor: pointer;
}

.info-card {
    background-color: #fff;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
    padding: 8px 12px 12px 12px;
    font-size: 12px;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.6;
}

body.dark-mode .info-card {
    background-color: #2a2a2a;
    border-color: #444;
}

.hidden {
    display: none;
}

/* ==================== AUTH PAGE STYLES ==================== */
.auth-form {
    max-width: 360px;
    margin: 80px auto;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: #fff;
}

body.dark-mode .auth-form {
    background: #2a2a2a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.auth-form input:focus,
.auth-form button:focus {
    outline: none;
    border-color: #2c5f2d;
}

/* ==================== SUCCESS POPUP STYLES ==================== */
.success-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.success-popup-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

body.dark-mode .success-popup-content {
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #444;
}

.success-icon-container {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #059669, #047857);
    /* Darker, richer green */
    border-radius: 50%;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px -5px rgba(5, 150, 105, 0.5);
    /* Stronger shadow */
    animation: pulse 2s infinite;
}

.success-icon {
    font-size: 48px;
    /* Larger icon */
    font-weight: bold;
    color: #ffffff;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    /* Subtle shadow for contrast */
}

.success-title {
    font-size: 24px;
    font-weight: 800;
    color: #111827;
    margin-bottom: 12px;
}

body.dark-mode .success-title {
    color: #fff;
}

.success-message {
    font-size: 16px;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 32px;
}

body.dark-mode .success-message {
    color: #9ca3af;
}

.success-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
    width: 100%;
}

.success-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3);
}

.success-btn:active {
    transform: translateY(0);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(5, 150, 105, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(5, 150, 105, 0);
    }
}

/* ==================== GRAPH TOOLBAR STYLES ==================== */
.graph-toolbar {
    background-color: #f0f0f0;
    border-bottom: 1px solid #d0d0d0;
    padding: 8px 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 8px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

body.dark-mode .graph-toolbar {
    background-color: #3a3a3a;
    border-bottom-color: #555;
}

.graph-toolbar-btn {
    background: #ffffff;
    border: 1px solid #c0c0c0;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 32px;
    position: relative;
    user-select: none;
    white-space: nowrap;
}

.graph-toolbar-btn:hover {
    background: #e8e8e8;
    border-color: #a0a0a0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.graph-toolbar-btn:active {
    transform: translateY(0);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.graph-toolbar-btn.active {
    background: #2c5f2d;
    color: #ffffff;
    border-color: #1a3a1b;
}

.graph-toolbar-btn.active:hover {
    background: #1a3a1b;
}

body.dark-mode .graph-toolbar-btn {
    background: #555555;
    border-color: #666666;
    color: #ffffff;
}

body.dark-mode .graph-toolbar-btn:hover {
    background: #666666;
    border-color: #777777;
}

body.dark-mode .graph-toolbar-btn.active {
    background: #90c9a4;
    color: #1a1a1a;
    border-color: #6ab87d;
}

body.dark-mode .graph-toolbar-btn.active:hover {
    background: #7ab88f;
}

.graph-toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.graph-toolbar-tooltip {
    position: absolute;
    background: #333333;
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10001;
    pointer-events: none;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease forwards;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.graph-toolbar-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #333333;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.graph-toolbar-btn.feedback-success {
    animation: buttonSuccess 0.3s ease;
}

.graph-toolbar-btn.feedback-error {
    animation: buttonError 0.3s ease;
}

@keyframes buttonSuccess {
    0% {
        background: #ffffff;
    }
    50% {
        background: #90c9a4;
        box-shadow: 0 0 8px rgba(144, 201, 164, 0.5);
    }
    100% {
        background: #ffffff;
    }
}

@keyframes buttonError {
    0%, 100% {
        background: #ffffff;
    }
    50% {
        background: #f87171;
        box-shadow: 0 0 8px rgba(248, 113, 113, 0.5);
    }
}

/* Separator in toolbar */
.graph-toolbar-separator {
    width: 1px;
    height: 24px;
    background-color: #d0d0d0;
    margin: 0 4px;
}

body.dark-mode .graph-toolbar-separator {
    background-color: #555;
}

/* Chart options menu */
.chart-options-menu {
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: menuSlideIn 0.2s ease;
}

body.dark-mode .chart-options-menu {
    background: #2a2a2a;
    border-color: #555;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chart-options-menu > div {
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    color: #333333;
}

body.dark-mode .chart-options-menu > div {
    color: #ffffff;
    border-bottom-color: #444;
}

.chart-options-menu > div:last-child {
    border-bottom: none;
}

.chart-options-menu > div:hover {
    background-color: #f5f5f5;
}

body.dark-mode .chart-options-menu > div:hover {
    background-color: #3a3a3a;
}

@keyframes menuSlideIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive toolbar */
@media (max-width: 768px) {
    .graph-toolbar {
        padding: 6px 8px;
        gap: 4px;
    }

    .graph-toolbar-btn {
        padding: 4px 8px;
        font-size: 12px;
        min-width: 32px;
        height: 28px;
    }

    .graph-toolbar-tooltip {
        font-size: 11px;
        padding: 4px 8px;
    }
}