:root {
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #6366f1;
    --primary-bg: #eef2ff;
    --accent: #06b6d4;
    --success: #10b981;
    --success-bg: #d1fae5;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    --danger: #ef4444;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Calculator Wrapper */
.bitwise-calculator-wrapper {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 40px;
}

/* Tool Cards */
.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 28px;
    transition: var(--transition);
}

.tool-card:hover {
    box-shadow: var(--shadow-medium);
}

.card-header {
    margin-bottom: 24px;
}

.card-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 8px 0;
}

.card-description {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

/* Input Grid */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.input-label i {
    color: var(--primary);
    font-size: 16px;
}

.number-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    
    font-size: 16px;
    color: var(--text-main);
    background: var(--surface);
    transition: var(--transition);
}

.number-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.number-input::placeholder {
    color: var(--text-light);
}

.input-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--surface-muted);
    border-radius: var(--radius);
    font-size: 13px;
}

.preview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-label {
    color: var(--text-muted);
    font-weight: 500;
}

.preview-value {
    
    font-weight: 600;
    color: var(--text-main);
    word-break: break-all;
    text-align: right;
}

/* Operations Grid */
.operations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.operation-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 100px;
}

.operation-btn:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.operation-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-medium);
}

.operation-btn.active .op-symbol,
.operation-btn.active .op-name {
    color: white;
}

.op-symbol {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.op-name {
    font-size: 14px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.btn-primary,
.btn-secondary,
.btn-success,
.btn-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

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

.btn-secondary {
    background: var(--surface);
    color: var(--text-main);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-muted);
    border-color: var(--border-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* Results Card */
.results-card {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border: 2px solid var(--primary);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
}

.result-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-soft);
}

.result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--primary-bg);
    border-radius: var(--radius);
    color: var(--primary);
    font-size: 20px;
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.result-value {
    
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    word-break: break-all;
}

/* Step Explanation */
.step-explanation {
    margin-top: 24px;
    padding: 20px;
    background: var(--surface-muted);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.step-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 16px 0;
}

.step-title i {
    color: var(--primary);
}

.steps-content {
    
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-main);
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Result Actions */
.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* Truth Table */
.truth-table-card {
    background: linear-gradient(135deg, #fef3c7 0%, #ffffff 100%);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

.truth-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.truth-table th {
    background: var(--primary);
    color: white;
    padding: 14px 20px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.truth-table td {
    padding: 14px 20px;
    text-align: center;
    
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
}

.truth-table tr:last-child td {
    border-bottom: none;
}

.truth-table tr:nth-child(even) {
    background: var(--surface-muted);
}

.truth-table tr:hover {
    background: var(--primary-bg);
}

/* Mobile Responsive */
@media (max-width: 767px) {
    .tool-card {
        padding: 20px;
    }

    .card-title {
        font-size: 20px;
    }

    .input-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .operations-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .operation-btn {
        min-height: 90px;
        padding: 16px 12px;
    }

    .op-symbol {
        font-size: 28px;
    }

    .op-name {
        font-size: 12px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-info {
        width: 100%;
        justify-content: center;
    }

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

    .result-item {
        padding: 16px;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions button {
        width: 100%;
    }

    .truth-table {
        font-size: 14px;
    }

    .truth-table th,
    .truth-table td {
        padding: 10px 12px;
    }

    .steps-content {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .tool-card {
        padding: 16px;
    }

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

    .operation-btn {
        min-height: 80px;
    }

    .op-symbol {
        font-size: 24px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --surface: #1e293b;
        --surface-muted: #0f172a;
        --border: #334155;
        --border-hover: #475569;
        --text-main: #f1f5f9;
        --text-muted: #94a3b8;
        --text-light: #64748b;
        --primary-bg: #312e81;
    }
}
