:root {
    --primary-blue: #1a73e8;
    --blue-800: #0d47a1;
    --blue-700: #1565c0;
    --blue-400: #42a5f5;
    --blue-50: #e3f2fd;
    --blue-100: #bbdefb;
    --green-800: #2e7d32;
    --green-300: #81c784;
    --green-200: #a5d6a7;
    --green-100: #c8e6c9;
    --green-50: #e8f5e9;
    --red-700: #c62828;
    --red-400: #ef5350;
    --red-50: #ffebee;
    --grey-700: #616161;
    --grey-600: #757575;
    --grey-500: #9e9e9e;
    --grey-400: #bdbdbd;
    --grey-300: #e0e0e0;
    --grey-200: #eeeeee;
    --grey-100: #f5f5f5;
    --grey-50: #fafafa;
    --orange: #ff9800;
    --white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #333;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--white);
    box-shadow: var(--shadow-lg);
}

.app-header {
    padding: 20px;
    border-bottom: 1px solid var(--grey-200);
    background: var(--white);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-icon {
    font-size: 40px;
    color: var(--primary-blue);
}

.header-content h1 {
    font-size: 36px;
    font-weight: 700;
    color: var(--blue-800);
    margin: 0;
}

.header-subtitle {
    font-size: 20px;
    color: var(--grey-700);
    margin-left: auto;
}

.main-content {
    flex: 1;
    padding: 20px;
}

.tabs-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.tab-buttons {
    display: flex;
    background: var(--grey-50);
    border-bottom: 1px solid var(--grey-200);
}

.tab-button {
    flex: 1;
    padding: 20px;
    background: none;
    border: none;
    font-size: 16px;
    font-weight: 500;
    color: var(--grey-600);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.tab-button:hover {
    background: var(--grey-100);
    color: var(--primary-blue);
}

.tab-button.active {
    background: var(--white);
    color: var(--primary-blue);
    border-bottom: 3px solid var(--primary-blue);
}

.tab-pane {
    display: none;
    padding: 20px;
    min-height: 700px;
}

.tab-pane.active {
    display: block;
}

.balancer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 700px;
}

.spacer-top,
.spacer-bottom {
    flex: 1;
}

.input-group {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.input-wrapper {
    position: relative;
    width: 900px;
}

.input-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--blue-400);
    font-size: 20px;
}

.equation-input {
    width: 100%;
    height: 60px;
    padding: 15px 20px 15px 60px;
    font-size: 16px;
    border: 2px solid var(--blue-400);
    border-radius: var(--radius-md);
    background: var(--grey-50);
    transition: all 0.3s ease;
}

.equation-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.button-group {
    display: flex;
    gap: 20px;
    margin: 20px 0;
}

.btn {
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: none;
}

.btn-primary {
    background: var(--primary-blue);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--blue-700);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    color: var(--grey-700);
    border: 2px solid var(--grey-300);
}

.btn-outline:hover {
    border-color: var(--grey-400);
    background: var(--grey-50);
}

.btn-secondary {
    background: var(--green-50);
    color: var(--green-800);
    border: 1px solid var(--green-200);
}

.btn-secondary:hover {
    background: var(--green-100);
}

.divider {
    height: 1px;
    background: var(--grey-200);
    margin: 20px 0;
    width: 100%;
}

.divider-small {
    height: 1px;
    background: var(--grey-200);
    margin: 10px 0;
    width: 100%;
}

.divider-medium {
    height: 1px;
    background: var(--grey-200);
    margin: 15px 0;
    width: 100%;
}

.copy-status {
    color: var(--grey-600);
    font-size: 14px;
    text-align: center;
    height: 24px;
}

.output-container {
    width: 100%;
    padding: 20px;
    border-radius: var(--radius-md);
    border: 2px solid var(--green-200);
    background: var(--green-50);
}

.output-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--green-800);
    margin-bottom: 20px;
}

.output-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.output-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.balanced-equation {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    flex: 1;
    line-height: 1.5;
    word-break: break-word;
}

.coefficients-text {
    font-size: 16px;
    color: var(--grey-700);
    flex: 1;
    line-height: 1.5;
}

.copy-btn {
    background: none;
    border: none;
    color: var(--grey-600);
    cursor: pointer;
    padding: 5px;
    transition: color 0.3s ease;
}

.copy-btn:hover {
    color: var(--primary-blue);
}

.solution-steps-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.btn-toggle-solution {
    background: var(--blue-50);
    color: var(--primary-blue);
    border: 1px solid var(--blue-100);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-toggle-solution:hover {
    background: var(--blue-100);
}

.solution-steps-container {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--green-300);
    border-radius: var(--radius-md);
    background: var(--green-100);
}

.solution-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.solution-icon {
    color: var(--blue-700);
    font-size: 20px;
}

.solution-header h4 {
    font-size: 18px;
    font-weight: 700;
    color: var(--blue-700);
}

.solution-divider {
    height: 2px;
    background: var(--green-300);
    margin: 10px 0 20px 0;
}

.solution-step {
    padding: 15px;
    margin-bottom: 10px;
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--blue-100);
}

.solution-step:nth-child(even) {
    background: var(--green-50);
    border-color: var(--green-200);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.step-number {
    width: 30px;
    height: 30px;
    background: var(--blue-700);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}

.step-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--blue-700);
}

.step-content {
    padding-left: 45px;
    font-size: 14px;
    color: var(--grey-700);
    line-height: 1.6;
}

.step-line {
    margin: 5px 0;
}

.error-container {
    width: 100%;
    padding: 15px;
    border-radius: var(--radius-md);
    background: var(--red-50);
    border: 1px solid var(--red-400);
    display: flex;
    align-items: center;
    gap: 15px;
}

.error-icon {
    color: var(--red-700);
    font-size: 20px;
}

.error-text {
    color: var(--red-700);
    font-size: 16px;
    font-weight: 500;
}

.examples-container {
    width: 100%;
    padding: 20px;
    border: 1px solid var(--grey-300);
    border-radius: var(--radius-lg);
    background: var(--grey-50);
    margin-top: 30px;
}

.examples-container h4 {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 15px;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.example-btn {
    padding: 12px 20px;
    background: var(--white);
    border: 1px solid var(--grey-300);
    border-radius: var(--radius-md);
    color: var(--primary-blue);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.example-btn:hover {
    background: var(--blue-50);
    border-color: var(--primary-blue);
    transform: translateY(-2px);
}

/* Stoichiometry Tab Styles */
.stoichiometry-container {
    min-height: 700px;
}

.stoich-equation-text {
    font-size: 14px;
    color: var(--grey-600);
    text-align: center;
    padding: 20px;
}

.scrollable-grid-container {
    border: 1px solid var(--grey-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    background: var(--white);
    height: 350px;
    overflow: auto;
}

.stoichiometry-grid {
    min-width: 1200px;
}

.grid-header,
.grid-row,
.grams-row,
.moles-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.grid-label {
    width: 120px;
    text-align: right;
    padding-right: 10px;
    font-size: 12px;
    font-weight: 700;
}

.compound-cell {
    width: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 5px;
}

.compound-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
}

.compound-mw {
    font-size: 11px;
    color: var(--grey-600);
}

.compound-reactant {
    color: var(--blue-700);
}

.compound-product {
    color: var(--green-700);
}

.arrow-cell {
    width: 50px;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
}

.checkbox-cell,
.input-cell {
    width: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.input-with-copy {
    display: flex;
    gap: 5px;
    align-items: center;
}

.stoich-input {
    width: 100px;
    height: 35px;
    padding: 8px;
    font-size: 12px;
    border: 1px solid var(--grey-400);
    border-radius: var(--radius-sm);
    background: var(--grey-50);
}

.stoich-input:disabled {
    background: var(--grey-100);
    color: var(--grey-500);
}

.stoich-input:focus {
    outline: none;
    border-color: var(--primary-blue);
}

.stoich-input.selected {
    border-color: var(--primary-blue);
    background: var(--white);
}

.stoich-result-text {
    font-size: 14px;
    text-align: center;
    padding: 10px;
    min-height: 20px;
}

.center-button {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--grey-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--grey-600);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--red-700);
}

.modal-body {
    padding: 20px;
    overflow: auto;
    flex: 1;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--grey-200);
    display: flex;
    justify-content: flex-end;
    gap: 20px;
}

/* Table Styles */
.data-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--grey-300);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.data-table th {
    background: var(--grey-100);
    padding: 15px;
    text-align: left;
    font-size: 14px;
    font-weight: 700;
    color: #333;
    border-bottom: 1px solid var(--grey-300);
}

.data-table td {
    padding: 15px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--grey-200);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: var(--grey-50);
}

.compound-cell-data {
    font-weight: 700;
    font-size: 14px;
}

.compound-reactant-data {
    color: var(--blue-700);
}

.compound-product-data {
    color: var(--green-700);
}

.type-cell {
    font-weight: 500;
    font-size: 14px;
}

.type-reactant {
    color: var(--primary-blue);
}

.type-product {
    color: var(--green-800);
}

/* Checkbox Styles */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.stoich-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.stoich-checkbox:checked {
    accent-color: var(--primary-blue);
}

/* Footer */
.app-footer {
    padding: 20px;
    text-align: center;
    color: var(--grey-500);
    font-size: 12px;
    border-top: 1px solid var(--grey-200);
    background: var(--white);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .input-wrapper {
        width: 100%;
        max-width: 900px;
    }

    .balancer-container {
        min-height: auto;
    }

    .spacer-top,
    .spacer-bottom {
        flex: none;
        height: 20px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .header-subtitle {
        margin-left: 0;
    }

    .tab-button {
        padding: 15px;
        font-size: 14px;
    }

    .equation-input {
        height: 50px;
        font-size: 14px;
        padding: 12px 20px 12px 50px;
    }

    .input-icon {
        left: 15px;
        font-size: 16px;
    }

    .button-group {
        flex-direction: column;
        width: 100%;
        max-width: 300px;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .examples-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }

    .scrollable-grid-container {
        overflow-x: auto;
    }

    .stoichiometry-grid {
        min-width: 800px;
    }

    .stoich-input.selected {
        border-color: var(--primary-blue) !important;
        background: var(--white) !important;
        box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
    }

    .stoich-input.disabled {
        background: var(--grey-100) !important;
        color: var(--grey-500) !important;
        cursor: not-allowed;
    }

    .input-with-copy {
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .input-with-copy .copy-btn {
        background: none;
        border: none;
        color: var(--grey-500);
        cursor: pointer;
        padding: 5px;
        font-size: 14px;
    }

    .input-with-copy .copy-btn:hover {
        color: var(--primary-blue);
    }

    .stoich-checkbox:checked {
        accent-color: var(--primary-blue);
    }

    /* Fix modal scroll */
    .modal-body {
        max-height: 60vh;
        overflow-y: auto;
    }

    /* Error states */
    .error-message {
        color: var(--red-700);
        background: var(--red-50);
        border: 1px solid var(--red-200);
        padding: 10px;
        border-radius: 5px;
        margin: 10px 0;
    }

    .success-message {
        color: var(--green-700);
        background: var(--green-50);
        border: 1px solid var(--green-200);
        padding: 10px;
        border-radius: 5px;
        margin: 10px 0;
    }
}